~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-23 11:21:11 UTC
  • mfrom: (1.1.16) (38.1.4 hardy-security)
  • Revision ID: package-import@ubuntu.com-20120223112111-rn9ruzg86juli2ec
Tags: 5.0.95-0ubuntu1
* SECURITY UPDATE: Update to 5.0.95 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2012-0075
  - CVE-2012-0087
  - CVE-2012-0101
  - CVE-2012-0102
  - CVE-2012-0114
  - CVE-2012-0484
  - CVE-2012-0490
* Dropped patches unnecessary with 5.0.95:
  - debian/patches/91_SECURITY_CVE-2007-5925.dpatch
  - debian/patches/95_SECURITY_CVE-2008-3963.dpatch
  - debian/patches/96_SECURITY_CVE-2008-4098.dpatch
  - debian/patches/97_CVE-2008-4456.dpatch
  - debian/patches/97_CVE-2009-2446.dpatch
  - debian/patches/97_CVE-2009-4019.dpatch
  - debian/patches/97_CVE-2009-4030.dpatch
  - debian/patches/98_CVE-2009-4484.dpatch
  - debian/patches/99_ssl_test_certs.dpatch
  - debian/patches/100_CVE-2010-1850.dpatch
  - debian/patches/101_CVE-2010-1849.dpatch
  - debian/patches/102_CVE-2010-1848.dpatch
  - debian/patches/103_CVE-2010-1626.dpatch
  - debian/patches/98_CVE-2010-3677.dpatch
  - debian/patches/98_CVE-2010-3680.dpatch
  - debian/patches/98_CVE-2010-3681.dpatch
  - debian/patches/98_CVE-2010-3682.dpatch
  - debian/patches/98_CVE-2010-3833.dpatch
  - debian/patches/98_CVE-2010-3834.dpatch
  - debian/patches/98_CVE-2010-3835.dpatch
  - debian/patches/98_CVE-2010-3836.dpatch
  - debian/patches/98_CVE-2010-3837.dpatch
  - debian/patches/98_CVE-2010-3838.dpatch
  - debian/patches/98_CVE-2010-3840.dpatch
  - debian/patches/45_warn-CLI-passwords.dpatch
  - debian/patches/50_fix_mysqldump.dpatch
  - debian/patches/51_incorrect-order.dpatch
  - debian/patches/52_ndb-gcc-4.2.dpatch
  - debian/patches/53_integer-gcc-4.2.dpatch
  - debian/patches/54_ssl-client-support.dpatch
  - debian/patches/55_testsuite-2008.dpatch
  - debian/patches/58-disable-ndb-backup-print.dpatch
  - debian/patches/59-fix-mysql-replication-logs.dpatch
  - debian/patches/86_PATH_MAX.dpatch
  - debian/patches/90_upstreamdebiandir.dpatch
  - debian/patches/92_fix_order_by32202.dpatch
  - debian/patches/93_fix_user_setup_on_localhost.dpatch
  - debian/patches/94_fix_mysqldump_with_old_versions.dpatch
  - debian/patches/56-mysqlhotcopy-invalid-dbtable.dpatch
  - debian/patches/57-fix-mysqlslowdump-config.dpatch
* debian/mysql-client-5.0.docs, debian/mysql-server-5.0.docs: removed
  EXCEPTIONS-CLIENT file
* debian/libmysqlclient15-dev.docs, debian/libmysqlclient15off.docs:
  removed, no longer necessary.
* debian/patches/25_mysys__default.c.dpatch: updated for 5.0.95.
* debian/mysql-server-5.0.files: change ndb_mgmd and ndbd manpage
  locations. Removed mysqlmanagerc.1 and mysqlmanager-pwgen.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Can't test with embedded server
2
2
-- source include/not_embedded.inc
3
3
 
 
4
# Save the initial number of concurrent sessions
 
5
--source include/count_sessions.inc
 
6
 
4
7
# simple test of grants
5
8
grant create view on test.* to test@localhost;
6
9
show grants for test@localhost;
26
29
connect (user1,localhost,mysqltest_1,,test);
27
30
connection user1;
28
31
 
 
32
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
29
33
create definer=root@localhost view v1 as select * from mysqltest.t1;
30
34
create view v1 as select * from mysqltest.t1;
31
35
# try to modify view without DROP privilege on it
 
36
--error ER_TABLEACCESS_DENIED_ERROR
32
37
alter view v1 as select * from mysqltest.t1;
 
38
--error ER_TABLEACCESS_DENIED_ERROR
33
39
create or replace view v1 as select * from mysqltest.t1;
34
40
# no CRETE VIEW privilege
 
41
--error ER_TABLEACCESS_DENIED_ERROR
35
42
create view mysqltest.v2  as select * from mysqltest.t1;
36
43
# no SELECT privilege
 
44
--error ER_TABLEACCESS_DENIED_ERROR
37
45
create view v2 as select * from mysqltest.t2;
38
46
 
39
47
connection root;
48
51
grant create view,drop,select on test.* to mysqltest_1@localhost;
49
52
 
50
53
connection user1;
51
 
# following 'use' command is workaround of bug #9582 and should be removed
 
54
# following 'use' command is workaround of Bug#9582 and should be removed
52
55
# when that bug will be fixed
53
56
use test;
54
57
alter view v1 as select * from mysqltest.t1;
76
79
connection user1;
77
80
select c from mysqltest.v1;
78
81
# there are no privileges on column 'd'
 
82
--error ER_COLUMNACCESS_DENIED_ERROR
79
83
select d from mysqltest.v1;
80
84
 
81
85
connection root;
96
99
connection user1;
97
100
select c from mysqltest.v1;
98
101
# there are no privileges on column 'd'
 
102
--error ER_COLUMNACCESS_DENIED_ERROR
99
103
select d from mysqltest.v1;
100
104
 
101
105
connection root;
111
114
--disable_warnings
112
115
create database mysqltest;
113
116
--enable_warnings
114
 
#prepare views and tables
 
117
# prepare views and tables
115
118
create table mysqltest.t1 (a int, b int);
116
119
create table mysqltest.t2 (a int, b int);
117
120
create view mysqltest.v1 (c,d) as select a+1,b+1 from mysqltest.t1;
118
121
create algorithm=temptable view mysqltest.v2 (c,d) as select a+1,b+1 from mysqltest.t1;
119
122
create view mysqltest.v3 (c,d) as select a+1,b+1 from mysqltest.t2;
120
123
create algorithm=temptable view mysqltest.v4 (c,d) as select a+1,b+1 from mysqltest.t2;
 
124
# v5: SHOW VIEW, but no SELECT
 
125
create view mysqltest.v5 (c,d) as select a+1,b+1 from mysqltest.t1;
121
126
grant select on mysqltest.v1 to mysqltest_1@localhost;
122
127
grant select on mysqltest.v2 to mysqltest_1@localhost;
123
128
grant select on mysqltest.v3 to mysqltest_1@localhost;
124
129
grant select on mysqltest.v4 to mysqltest_1@localhost;
 
130
grant show view on mysqltest.v5 to mysqltest_1@localhost;
125
131
 
126
132
connection user1;
127
 
# all selects works
 
133
# all SELECTs works, except v5 which lacks SELECT privs
128
134
select c from mysqltest.v1;
129
135
select c from mysqltest.v2;
130
136
select c from mysqltest.v3;
131
137
select c from mysqltest.v4;
 
138
--error ER_TABLEACCESS_DENIED_ERROR
 
139
select c from mysqltest.v5;
132
140
# test of show coluns
133
141
show columns from mysqltest.v1;
134
142
show columns from mysqltest.v2;
135
 
# but explain/show do not
 
143
# explain/show fail
 
144
--error ER_VIEW_NO_EXPLAIN
136
145
explain select c from mysqltest.v1;
 
146
--error ER_TABLEACCESS_DENIED_ERROR
137
147
show create view mysqltest.v1;
 
148
--error ER_VIEW_NO_EXPLAIN
138
149
explain select c from mysqltest.v2;
 
150
--error ER_TABLEACCESS_DENIED_ERROR
139
151
show create view mysqltest.v2;
 
152
--error ER_VIEW_NO_EXPLAIN
140
153
explain select c from mysqltest.v3;
 
154
--error ER_TABLEACCESS_DENIED_ERROR
141
155
show create view mysqltest.v3;
 
156
--error ER_VIEW_NO_EXPLAIN
142
157
explain select c from mysqltest.v4;
 
158
--error ER_TABLEACCESS_DENIED_ERROR
143
159
show create view mysqltest.v4;
 
160
--error ER_TABLEACCESS_DENIED_ERROR
 
161
explain select c from mysqltest.v5;
 
162
show create view mysqltest.v5;
144
163
 
 
164
# missing SELECT on underlying t1, no SHOW VIEW on v1 either.
 
165
--error ER_VIEW_NO_EXPLAIN
 
166
explain select c from mysqltest.v1;
 
167
# missing SHOW VIEW
 
168
--error ER_TABLEACCESS_DENIED_ERROR
 
169
show create view mysqltest.v1;
145
170
# allow to see one of underlying table
146
171
connection root;
 
172
grant show view on mysqltest.v1 to mysqltest_1@localhost;
147
173
grant select on mysqltest.t1 to mysqltest_1@localhost;
148
174
connection user1;
149
 
# EXPLAIN of view on above table works
 
175
# EXPLAIN works
150
176
explain select c from mysqltest.v1;
151
177
show create view mysqltest.v1;
 
178
# missing SHOW VIEW
 
179
--error ER_VIEW_NO_EXPLAIN
152
180
explain select c from mysqltest.v2;
 
181
--error ER_TABLEACCESS_DENIED_ERROR
153
182
show create view mysqltest.v2;
154
183
# but other EXPLAINs do not
 
184
--error ER_VIEW_NO_EXPLAIN
155
185
explain select c from mysqltest.v3;
 
186
--error ER_TABLEACCESS_DENIED_ERROR
156
187
show create view mysqltest.v3;
 
188
--error ER_VIEW_NO_EXPLAIN
157
189
explain select c from mysqltest.v4;
 
190
--error ER_TABLEACCESS_DENIED_ERROR
158
191
show create view mysqltest.v4;
 
192
# we have SHOW VIEW on v5, and  SELECT on t1 -- not enough
 
193
--error ER_TABLEACCESS_DENIED_ERROR
 
194
explain select c from mysqltest.v5;
 
195
# we can SHOW CREATE VIEW though
 
196
show create view mysqltest.v5;
159
197
 
160
198
# allow to see any view in mysqltest database
161
199
connection root;
179
203
show create view mysqltest.v1;
180
204
explain select c from mysqltest.v2;
181
205
show create view mysqltest.v2;
 
206
# have SHOW VIEW | SELECT on v3, but no SELECT on t2
 
207
--error ER_VIEW_NO_EXPLAIN
182
208
explain select c from mysqltest.v3;
183
209
show create view mysqltest.v3;
 
210
# have SHOW VIEW | SELECT on v4, but no SELECT on t2
 
211
--error ER_VIEW_NO_EXPLAIN
184
212
explain select c from mysqltest.v4;
185
213
show create view mysqltest.v4;
186
214
 
222
250
update v2 set a=a+c;
223
251
select * from t1;
224
252
# no rights on column
 
253
--error ER_COLUMNACCESS_DENIED_ERROR
225
254
update t2,v2 set v2.c=v2.a+v2.c where t2.x=v2.c;
 
255
--error ER_COLUMNACCESS_DENIED_ERROR
226
256
update v2 set c=a+c;
227
257
# no rights for view
 
258
--error ER_TABLEACCESS_DENIED_ERROR
228
259
update t2,v3 set v3.a=v3.a+v3.c where t2.x=v3.c;
 
260
--error ER_TABLEACCESS_DENIED_ERROR
229
261
update v3 set a=a+c;
230
262
 
231
263
use test;
263
291
delete v1 from t2,v1 where t2.x=v1.c;
264
292
select * from t1;
265
293
# no rights for view
 
294
--error ER_TABLEACCESS_DENIED_ERROR
266
295
delete v2 from t2,v2 where t2.x=v2.c;
 
296
--error ER_TABLEACCESS_DENIED_ERROR
267
297
delete from v2 where c < 4;
268
298
 
269
299
use test;
299
327
insert into v1 select x,y from t2;
300
328
select * from t1;
301
329
# no rights for view
 
330
--error ER_TABLEACCESS_DENIED_ERROR
302
331
insert into v2 values (5,6);
 
332
--error ER_TABLEACCESS_DENIED_ERROR
303
333
insert into v2 select x,y from t2;
304
334
 
305
335
use test;
329
357
create view v1 as select * from mysqltest.t1;
330
358
create view v2 as select b from mysqltest.t2;
331
359
# There are not rights on mysqltest.v1
 
360
--error ER_TABLEACCESS_DENIED_ERROR
332
361
create view mysqltest.v1 as select * from mysqltest.t1;
333
362
# There are not any rights on mysqltest.t2.a
 
363
--error ER_COLUMNACCESS_DENIED_ERROR
334
364
create view v3 as select a from mysqltest.t2;
335
365
 
336
366
# give CREATE VIEW privileges (without any privileges for result column)
352
380
 
353
381
 
354
382
# Expression need select privileges
 
383
--error ER_COLUMNACCESS_DENIED_ERROR
355
384
create view v4 as select b+1 from mysqltest.t2;
356
385
 
357
386
connection root;
358
387
grant create view,update,select on test.* to mysqltest_1@localhost;
359
388
connection user1;
 
389
--error ER_COLUMNACCESS_DENIED_ERROR
360
390
create view v4 as select b+1 from mysqltest.t2;
361
391
 
362
392
connection root;
411
439
# check view definer information
412
440
show create view v1;
413
441
revoke select on mysqltest.t1 from mysqltest_1@localhost;
 
442
--error ER_VIEW_INVALID
414
443
select * from v1;
415
444
grant select on mysqltest.t1 to mysqltest_1@localhost;
416
445
select * from v1;
420
448
drop database mysqltest;
421
449
 
422
450
#
423
 
# rights on execution of view underlying functiond (BUG#9505)
 
451
# rights on execution of view underlying functiond (Bug#9505)
424
452
#
425
453
connection root;
426
454
--disable_warnings
453
481
use mysqltest;
454
482
select * from v1;
455
483
select * from v2;
 
484
--error ER_VIEW_INVALID
456
485
select * from v3;
 
486
--error ER_VIEW_INVALID
457
487
select * from v4;
 
488
--error ER_VIEW_INVALID
458
489
select * from v5;
459
490
use test;
460
491
 
505
533
connection root;
506
534
create view v5 as select * from v1;
507
535
revoke execute on function f2 from mysqltest_1@localhost;
 
536
--error ER_VIEW_INVALID
508
537
select * from v1;
 
538
--error ER_VIEW_INVALID
509
539
select * from v2;
510
540
select * from v3;
511
541
select * from v4;
 
542
--error ER_VIEW_INVALID
512
543
select * from v5;
513
544
 
514
545
drop view v1, v2, v3, v4, v5;
549
577
 
550
578
connection root;
551
579
revoke select on t1 from mysqltest_1@localhost;
 
580
--error ER_VIEW_INVALID
552
581
select * from v1;
 
582
--error ER_VIEW_INVALID
553
583
select * from v2;
554
584
select * from v3;
555
585
select * from v4;
 
586
--error ER_VIEW_INVALID
556
587
select * from v5;
557
588
 
558
589
#drop view v1, v2, v3, v4, v5;
588
616
use mysqltest;
589
617
select * from v1;
590
618
select * from v2;
 
619
--error ER_VIEW_INVALID
591
620
select * from v3;
 
621
--error ER_VIEW_INVALID
592
622
select * from v4;
 
623
--error ER_VIEW_INVALID
593
624
select * from v5;
594
625
use test;
595
626
 
604
632
drop database mysqltest;
605
633
 
606
634
#
607
 
# BUG#14256: definer in view definition is not fully qualified
 
635
# Bug#14256 definer in view definition is not fully qualified
608
636
#
609
637
--disable_warnings
610
638
drop view if exists v1;
 
639
drop table if exists t1;
611
640
--enable_warnings
612
641
 
613
642
# Backup anonymous users and remove them. (They get in the way of
640
669
select @v1def1, @v1def2, @v1def1=@v1def2;
641
670
 
642
671
connection root;
 
672
disconnect test14256;
643
673
drop user test14256;
644
674
 
645
675
# Restore the anonymous users.
649
679
drop table t1;
650
680
 
651
681
#
652
 
# BUG#14726: freeing stack variable in case of an error of opening
653
 
# a view when we have locked tables with LOCK TABLES statement.
 
682
# Bug#14726 freeing stack variable in case of an error of opening a view when
 
683
#           we have locked tables with LOCK TABLES statement.
654
684
#
655
685
connection root;
656
686
--disable_warnings
667
697
 
668
698
use mysqltest;
669
699
LOCK TABLES v1 READ;
 
700
--error ER_TABLEACCESS_DENIED_ERROR
670
701
SHOW CREATE TABLE v1;
671
702
UNLOCK TABLES;
672
703
use test;
678
708
drop database mysqltest;
679
709
 
680
710
#
681
 
# switch to default connaction
 
711
# switch to default connection
682
712
#
683
713
disconnect user1;
684
714
disconnect root;
695
725
drop view v2;
696
726
 
697
727
#
698
 
# Bug#18681: View privileges are broken
 
728
# Bug#18681 View privileges are broken
699
729
#
700
730
CREATE DATABASE mysqltest1;
701
731
CREATE USER readonly@localhost;
716
746
GRANT DELETE ON mysqltest1.v_td TO readonly@localhost;
717
747
GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost;
718
748
 
719
 
CONNECT (n1,localhost,readonly,,);
720
 
CONNECTION n1;
 
749
connect (n1,localhost,readonly,,);
 
750
connection n1;
721
751
 
722
 
--error 1356
 
752
--error ER_VIEW_INVALID
723
753
SELECT * FROM mysqltest1.v_t1;
724
 
--error 1356
 
754
--error ER_VIEW_INVALID
725
755
INSERT INTO mysqltest1.v_t1 VALUES(4);
726
 
--error 1356
 
756
--error ER_VIEW_INVALID
727
757
DELETE FROM mysqltest1.v_t1 WHERE x = 1;
728
 
--error 1356
 
758
--error ER_VIEW_INVALID
729
759
UPDATE mysqltest1.v_t1 SET x = 3 WHERE x = 2;
730
 
--error 1356
 
760
--error ER_VIEW_INVALID
731
761
UPDATE mysqltest1.v_t1 SET x = 3;
732
 
--error 1356
 
762
--error ER_VIEW_INVALID
733
763
DELETE FROM mysqltest1.v_t1;
734
 
--error 1356
 
764
--error ER_VIEW_INVALID
735
765
SELECT 1 FROM mysqltest1.v_t1;
736
 
--error 1142
 
766
--error ER_TABLEACCESS_DENIED_ERROR
737
767
SELECT * FROM mysqltest1.t1;
738
768
 
739
769
SELECT * FROM mysqltest1.v_ts;
740
 
--error 1142
 
770
--error ER_TABLEACCESS_DENIED_ERROR
741
771
SELECT * FROM mysqltest1.v_ts, mysqltest1.t1 WHERE mysqltest1.t1.x = mysqltest1.v_ts.x;
742
 
--error 1142
 
772
--error ER_TABLEACCESS_DENIED_ERROR
743
773
SELECT * FROM mysqltest1.v_ti;
744
774
 
745
 
--error 1142
 
775
--error ER_TABLEACCESS_DENIED_ERROR
746
776
INSERT INTO mysqltest1.v_ts VALUES (100);
747
777
INSERT INTO mysqltest1.v_ti VALUES (100);
748
778
 
749
 
--error 1142
 
779
--error ER_TABLEACCESS_DENIED_ERROR
750
780
UPDATE mysqltest1.v_ts SET x= 200 WHERE x = 100;
751
 
--error 1142
 
781
--error ER_TABLEACCESS_DENIED_ERROR
752
782
UPDATE mysqltest1.v_ts SET x= 200;
753
783
UPDATE mysqltest1.v_tu SET x= 200 WHERE x = 100;
754
784
UPDATE mysqltest1.v_tus SET x= 200 WHERE x = 100;
755
785
UPDATE mysqltest1.v_tu SET x= 200;
756
786
 
757
 
--error 1142
 
787
--error ER_TABLEACCESS_DENIED_ERROR
758
788
DELETE FROM mysqltest1.v_ts WHERE x= 200;
759
 
--error 1142
 
789
--error ER_TABLEACCESS_DENIED_ERROR
760
790
DELETE FROM mysqltest1.v_ts;
761
 
--error 1143
 
791
--error ER_COLUMNACCESS_DENIED_ERROR
762
792
DELETE FROM mysqltest1.v_td WHERE x= 200;
763
793
DELETE FROM mysqltest1.v_tds WHERE x= 200;
764
794
DELETE FROM mysqltest1.v_td;
765
795
 
766
 
CONNECTION default;
 
796
connection default;
 
797
disconnect n1;
767
798
DROP VIEW mysqltest1.v_tds;
768
799
DROP VIEW mysqltest1.v_td;
769
800
DROP VIEW mysqltest1.v_tus;
776
807
DROP DATABASE mysqltest1;
777
808
 
778
809
#
779
 
# BUG#14875: Bad view DEFINER makes SHOW CREATE VIEW fail
 
810
# Bug#14875 Bad view DEFINER makes SHOW CREATE VIEW fail
780
811
#
781
812
CREATE TABLE t1 (a INT PRIMARY KEY);
782
813
INSERT INTO t1 VALUES (1), (2), (3);
783
814
CREATE DEFINER = 'no-such-user'@localhost VIEW v AS SELECT a from t1;
784
 
#--warning 1448
 
815
#--warning ER_VIEW_OTHER_USER
785
816
SHOW CREATE VIEW v;
786
 
--error 1449
 
817
--error ER_NO_SUCH_USER
787
818
SELECT * FROM v;
788
819
DROP VIEW v;
789
820
DROP TABLE t1;
790
821
USE test;
791
822
 
792
823
#
793
 
# Bug#20363: Create view on just created view is now denied
 
824
# Bug#20363 Create view on just created view is now denied
794
825
#
795
826
eval CREATE USER mysqltest_db1@localhost identified by 'PWD';
796
827
eval GRANT ALL ON mysqltest_db1.* TO mysqltest_db1@localhost WITH GRANT OPTION;
821
852
SELECT * from view3;
822
853
 
823
854
connection default;
 
855
disconnect session1;
824
856
DROP VIEW mysqltest_db1.view3;
825
857
DROP VIEW mysqltest_db1.view2;
826
858
DROP VIEW mysqltest_db1.view1;
828
860
DROP SCHEMA mysqltest_db1;
829
861
DROP USER mysqltest_db1@localhost;
830
862
#
831
 
# BUG#20482: failure on Create join view with sources views/tables 
832
 
#             in different schemas
 
863
# Bug#20482 failure on Create join view with sources views/tables
 
864
#           in different schemas
833
865
#
834
866
--disable_warnings
835
867
CREATE DATABASE test1;
839
871
CREATE TABLE test1.t0 (a VARCHAR(20));
840
872
CREATE TABLE test2.t1 (a VARCHAR(20));
841
873
CREATE VIEW  test2.t3 AS SELECT * FROM test1.t0;
842
 
CREATE OR REPLACE VIEW test.v1 AS 
 
874
CREATE OR REPLACE VIEW test.v1 AS
843
875
  SELECT ta.a AS col1, tb.a AS col2 FROM test2.t3 ta, test2.t1 tb;
844
876
 
845
877
DROP VIEW test.v1;
850
882
 
851
883
 
852
884
#
853
 
# BUG#20570: CURRENT_USER() in a VIEW with SQL SECURITY DEFINER
854
 
# returns invoker name
 
885
# Bug#20570 CURRENT_USER() in a VIEW with SQL SECURITY DEFINER returns
 
886
#           invoker name
855
887
#
856
888
--disable_warnings
857
889
DROP VIEW IF EXISTS v1;
910
942
 
911
943
 
912
944
#
913
 
# Bug#17254: Error for DEFINER security on VIEW provides too much info
 
945
# Bug#17254 Error for DEFINER security on VIEW provides too much info
914
946
#
915
947
connect (root,localhost,root,,);
916
948
connection root;
934
966
connect (inv,localhost,inv_17254,,db17254);
935
967
connection inv;
936
968
--echo for a user
937
 
--error 1142
 
969
--error ER_TABLEACCESS_DENIED_ERROR
938
970
SELECT * FROM v1;
939
971
 
940
972
connection root;
941
973
--echo for a superuser
942
 
--error 1449
 
974
--error ER_NO_SUCH_USER
943
975
SELECT * FROM v1;
944
976
DROP USER inv_17254@localhost;
945
977
DROP DATABASE db17254;
948
980
 
949
981
 
950
982
#
951
 
# BUG#24404: strange bug with view+permission+prepared statement
 
983
# Bug#24404 strange bug with view+permission+prepared statement
952
984
#
953
985
--disable_warnings
954
986
DROP DATABASE IF EXISTS mysqltest_db1;
1016
1048
DROP USER mysqltest_u2@localhost;
1017
1049
 
1018
1050
#
1019
 
# Bug#26813: The SUPER privilege is wrongly required to alter a view created
1020
 
#            by another user.
 
1051
# Bug#26813 The SUPER privilege is wrongly required to alter a view created
 
1052
#           by another user.
1021
1053
#
1022
1054
connection root;
1023
1055
CREATE DATABASE db26813;
1049
1081
disconnect u1;
1050
1082
 
1051
1083
--echo #
1052
 
--echo # Bug#29908: A user can gain additional access through the ALTER VIEW.
 
1084
--echo # Bug#29908 A user can gain additional access through the ALTER VIEW.
1053
1085
--echo #
1054
1086
connection root;
1055
1087
CREATE DATABASE mysqltest_29908;
1094
1126
--echo #######################################################################
1095
1127
 
1096
1128
#
1097
 
# BUG#24040: Create View don't succed with "all privileges" on a database.
 
1129
# Bug#24040 Create View don't succed with "all privileges" on a database.
1098
1130
#
1099
1131
 
1100
1132
# Prepare.
1178
1210
 
1179
1211
# Cleanup.
1180
1212
 
 
1213
disconnect bug24040_con;
1181
1214
 
1182
1215
DROP DATABASE mysqltest1;
1183
1216
DROP DATABASE mysqltest2;
1184
1217
DROP USER mysqltest_u1@localhost;
1185
1218
 
 
1219
 
 
1220
#
 
1221
# Bug#41354 Access control is bypassed when all columns of a view are
 
1222
#           selected by * wildcard
 
1223
 
 
1224
CREATE DATABASE db1;
 
1225
USE db1;
 
1226
CREATE TABLE t1(f1 INT, f2 INT);
 
1227
CREATE VIEW v1 AS SELECT f1, f2 FROM t1;
 
1228
 
 
1229
GRANT SELECT (f1) ON t1 TO foo;
 
1230
GRANT SELECT (f1) ON v1 TO foo;
 
1231
 
 
1232
connect (addconfoo, localhost, foo,,);
 
1233
connection addconfoo;
 
1234
USE db1;
 
1235
 
 
1236
SELECT f1 FROM t1;
 
1237
--error ER_COLUMNACCESS_DENIED_ERROR
 
1238
SELECT f2 FROM t1;
 
1239
--error ER_TABLEACCESS_DENIED_ERROR
 
1240
SELECT * FROM t1;
 
1241
 
 
1242
SELECT f1 FROM v1;
 
1243
--error ER_COLUMNACCESS_DENIED_ERROR
 
1244
SELECT f2 FROM v1;
 
1245
--error ER_TABLEACCESS_DENIED_ERROR
 
1246
SELECT * FROM v1;
 
1247
 
 
1248
connection default;
 
1249
disconnect root;
 
1250
disconnect addconfoo;
 
1251
USE test;
 
1252
REVOKE SELECT (f1) ON db1.t1 FROM foo;
 
1253
REVOKE SELECT (f1) ON db1.v1 FROM foo;
 
1254
DROP USER foo;
 
1255
DROP VIEW db1.v1;
 
1256
DROP TABLE db1.t1;
 
1257
DROP DATABASE db1;
 
1258
 
 
1259
connection default;
 
1260
 
 
1261
 
 
1262
--echo Bug #11765687/#58677: 
 
1263
--echo No privilege on table/view, but can know #rows / underlying table's name
 
1264
 
 
1265
# As a root-like user
 
1266
connect (root,localhost,root,,test);
 
1267
connection root;
 
1268
 
 
1269
create database mysqltest1;
 
1270
create table mysqltest1.t1 (i int);
 
1271
create table mysqltest1.t2 (j int);
 
1272
create table mysqltest1.t3 (k int, secret int);
 
1273
 
 
1274
create user alice@localhost;
 
1275
create user bob@localhost;
 
1276
create user cecil@localhost;
 
1277
create user dan@localhost;
 
1278
create user eugene@localhost;
 
1279
create user fiona@localhost;
 
1280
create user greg@localhost;
 
1281
create user han@localhost;
 
1282
create user inga@localhost;
 
1283
create user jamie@localhost;
 
1284
create user karl@localhost;
 
1285
create user lena@localhost;
 
1286
create user mhairi@localhost;
 
1287
create user noam@localhost;
 
1288
create user olga@localhost;
 
1289
create user pjotr@localhost;
 
1290
create user quintessa@localhost;
 
1291
 
 
1292
grant all privileges on mysqltest1.* to alice@localhost with grant option;
 
1293
 
 
1294
#
 
1295
--echo ... as alice
 
1296
connect (test11765687,localhost,alice,,mysqltest1);
 
1297
connection test11765687;
 
1298
 
 
1299
create view v1 as select * from t1;
 
1300
create view v2 as select * from v1, t2;
 
1301
create view v3 as select k from t3;
 
1302
 
 
1303
grant select            on mysqltest1.v1 to bob@localhost;
 
1304
 
 
1305
grant show view         on mysqltest1.v1 to cecil@localhost;
 
1306
 
 
1307
grant select, show view on mysqltest1.v1 to dan@localhost;
 
1308
grant select            on mysqltest1.t1 to dan@localhost;
 
1309
 
 
1310
grant select            on mysqltest1.*  to eugene@localhost;
 
1311
 
 
1312
grant select, show view on mysqltest1.v2 to fiona@localhost;
 
1313
 
 
1314
grant select, show view on mysqltest1.v2 to greg@localhost;
 
1315
grant         show view on mysqltest1.v1 to greg@localhost;
 
1316
 
 
1317
grant select(k)         on mysqltest1.t3 to han@localhost;
 
1318
grant select, show view on mysqltest1.v3 to han@localhost;
 
1319
 
 
1320
grant select            on mysqltest1.t1 to inga@localhost;
 
1321
grant select            on mysqltest1.t2 to inga@localhost;
 
1322
grant select            on mysqltest1.v1 to inga@localhost;
 
1323
grant select, show view on mysqltest1.v2 to inga@localhost;
 
1324
 
 
1325
grant select            on mysqltest1.t1 to jamie@localhost;
 
1326
grant select            on mysqltest1.t2 to jamie@localhost;
 
1327
grant         show view on mysqltest1.v1 to jamie@localhost;
 
1328
grant select, show view on mysqltest1.v2 to jamie@localhost;
 
1329
 
 
1330
grant select            on mysqltest1.t1 to karl@localhost;
 
1331
grant select            on mysqltest1.t2 to karl@localhost;
 
1332
grant select, show view on mysqltest1.v1 to karl@localhost;
 
1333
grant select            on mysqltest1.v2 to karl@localhost;
 
1334
 
 
1335
grant select            on mysqltest1.t1 to lena@localhost;
 
1336
grant select            on mysqltest1.t2 to lena@localhost;
 
1337
grant select, show view on mysqltest1.v1 to lena@localhost;
 
1338
grant         show view on mysqltest1.v2 to lena@localhost;
 
1339
 
 
1340
grant select            on mysqltest1.t1 to mhairi@localhost;
 
1341
grant select            on mysqltest1.t2 to mhairi@localhost;
 
1342
grant select, show view on mysqltest1.v1 to mhairi@localhost;
 
1343
grant select, show view on mysqltest1.v2 to mhairi@localhost;
 
1344
 
 
1345
grant select            on mysqltest1.t1 to noam@localhost;
 
1346
grant select, show view on mysqltest1.v1 to noam@localhost;
 
1347
grant select, show view on mysqltest1.v2 to noam@localhost;
 
1348
 
 
1349
grant select            on mysqltest1.t2 to olga@localhost;
 
1350
grant select, show view on mysqltest1.v1 to olga@localhost;
 
1351
grant select, show view on mysqltest1.v2 to olga@localhost;
 
1352
 
 
1353
grant select            on mysqltest1.t1 to pjotr@localhost;
 
1354
grant select            on mysqltest1.t2 to pjotr@localhost;
 
1355
grant select, show view on mysqltest1.v2 to pjotr@localhost;
 
1356
 
 
1357
grant select, show view on mysqltest1.v1 to quintessa@localhost;
 
1358
 
 
1359
disconnect test11765687;
 
1360
 
 
1361
#
 
1362
--echo ... as bob
 
1363
connect (test11765687,localhost,bob,,mysqltest1);
 
1364
connection test11765687;
 
1365
 
 
1366
select * from v1; # Should succeed.
 
1367
--error ER_VIEW_NO_EXPLAIN
 
1368
explain select * from v1; # fail, no SHOW_VIEW
 
1369
 
 
1370
disconnect test11765687;
 
1371
 
 
1372
#
 
1373
--echo ... as cecil
 
1374
connect (test11765687,localhost,cecil,,mysqltest1);
 
1375
connection test11765687;
 
1376
 
 
1377
--error ER_TABLEACCESS_DENIED_ERROR
 
1378
select * from v1; # fail, no SELECT
 
1379
--error ER_TABLEACCESS_DENIED_ERROR
 
1380
explain select * from v1; # fail, no SELECT
 
1381
 
 
1382
disconnect test11765687;
 
1383
 
 
1384
#
 
1385
--echo ... as dan
 
1386
connect (test11765687,localhost,dan,,mysqltest1);
 
1387
connection test11765687;
 
1388
 
 
1389
select * from v1; # Should succeed.
 
1390
explain select * from v1; # Should succeed.
 
1391
 
 
1392
disconnect test11765687;
 
1393
 
 
1394
#
 
1395
--echo ... as eugene
 
1396
connect (test11765687,localhost,eugene,,mysqltest1);
 
1397
connection test11765687;
 
1398
 
 
1399
select * from v1; # Should succeed.
 
1400
--error ER_VIEW_NO_EXPLAIN
 
1401
explain select * from v1; # fail, no SHOW_VIEW
 
1402
 
 
1403
disconnect test11765687;
 
1404
 
 
1405
#
 
1406
--echo ... as fiona
 
1407
connect (test11765687,localhost,fiona,,mysqltest1);
 
1408
connection test11765687;
 
1409
 
 
1410
select * from v2; # Should succeed.
 
1411
show create view v2; # Should succeed, but...
 
1412
--error ER_TABLEACCESS_DENIED_ERROR
 
1413
explain select * from t1; # fail, shouldn't see t1!
 
1414
--error ER_TABLEACCESS_DENIED_ERROR
 
1415
# err msg must give view name, no table names!!
 
1416
explain select * from v1; # fail, have no privs on v1!
 
1417
--error ER_TABLEACCESS_DENIED_ERROR
 
1418
explain select * from t2; # fail, have no privs on t2!
 
1419
--error ER_VIEW_NO_EXPLAIN
 
1420
explain select * from v2; # fail, shouldn't see t2!
 
1421
 
 
1422
disconnect test11765687;
 
1423
 
 
1424
#
 
1425
--echo ... as greg
 
1426
connect (test11765687,localhost,greg,,mysqltest1);
 
1427
connection test11765687;
 
1428
 
 
1429
select * from v2; # Should succeed.
 
1430
--error ER_TABLEACCESS_DENIED_ERROR
 
1431
explain select * from v1; # fail; no SELECT on v1!
 
1432
--error ER_VIEW_NO_EXPLAIN
 
1433
explain select * from v2; # fail; no SELECT on v1!
 
1434
 
 
1435
disconnect test11765687;
 
1436
 
 
1437
#
 
1438
--echo ... as han
 
1439
connect (test11765687,localhost,han,,mysqltest1);
 
1440
connection test11765687;
 
1441
 
 
1442
--error ER_TABLEACCESS_DENIED_ERROR
 
1443
select * from t3; # don't have privs on all columns,
 
1444
--error ER_TABLEACCESS_DENIED_ERROR
 
1445
explain select * from t3; # so EXPLAIN on "forbidden" columns should fail.
 
1446
select k from t3; # but we do have SELECT on column k though,
 
1447
explain select k from t3; # so EXPLAIN just on k should work,
 
1448
select * from v3; # and so should SELECT on view only using allowed columns
 
1449
explain select * from v3; # as should the associated EXPLAIN
 
1450
 
 
1451
disconnect test11765687;
 
1452
 
 
1453
#
 
1454
--echo ... as inga
 
1455
connect (test11765687,localhost,inga,,mysqltest1);
 
1456
connection test11765687;
 
1457
 
 
1458
select * from v2;
 
1459
# has sel/show on v2, sel on t1/t2, only sel v1
 
1460
# fail: lacks show on v1
 
1461
--error ER_VIEW_NO_EXPLAIN
 
1462
explain select * from v2;
 
1463
disconnect test11765687;
 
1464
 
 
1465
#
 
1466
--echo ... as jamie
 
1467
connect (test11765687,localhost,jamie,,mysqltest1);
 
1468
connection test11765687;
 
1469
 
 
1470
select * from v2;
 
1471
# has sel/show on v2, sel on t1/t2, only show v1
 
1472
# fail: lacks sel on v1
 
1473
--error ER_VIEW_NO_EXPLAIN
 
1474
explain select * from v2;
 
1475
disconnect test11765687;
 
1476
 
 
1477
#
 
1478
--echo ... as karl
 
1479
connect (test11765687,localhost,karl,,mysqltest1);
 
1480
connection test11765687;
 
1481
 
 
1482
select * from v2;
 
1483
# has sel only on v2, sel on t1/t2, sel/show v1
 
1484
# fail: lacks show on v2
 
1485
--error ER_VIEW_NO_EXPLAIN
 
1486
explain select * from v2;
 
1487
disconnect test11765687;
 
1488
 
 
1489
#
 
1490
--echo ... as lena
 
1491
 
 
1492
connect (test11765687,localhost,lena,,mysqltest1);
 
1493
connection test11765687;
 
1494
--error ER_TABLEACCESS_DENIED_ERROR
 
1495
select * from v2;
 
1496
# has show only on v2, sel on t1/t2, sel/show v1
 
1497
# fail: lacks sel on v2
 
1498
--error ER_TABLEACCESS_DENIED_ERROR
 
1499
explain select * from v2;
 
1500
disconnect test11765687;
 
1501
 
 
1502
#
 
1503
--echo ... as mhairi
 
1504
connect (test11765687,localhost,mhairi,,mysqltest1);
 
1505
connection test11765687;
 
1506
 
 
1507
select * from v2;
 
1508
# has sel/show on v2, sel on t1/t2, sel/show v1
 
1509
explain select * from v2;
 
1510
disconnect test11765687;
 
1511
 
 
1512
#
 
1513
--echo ... as noam
 
1514
connect (test11765687,localhost,noam,,mysqltest1);
 
1515
connection test11765687;
 
1516
 
 
1517
select * from v2;
 
1518
# has sel/show on v2, sel only on t1, sel/show v1 (no sel on t2!)
 
1519
--error ER_VIEW_NO_EXPLAIN
 
1520
explain select * from v2;
 
1521
disconnect test11765687;
 
1522
 
 
1523
#
 
1524
--echo ... as olga
 
1525
connect (test11765687,localhost,olga,,mysqltest1);
 
1526
connection test11765687;
 
1527
 
 
1528
select * from v2;
 
1529
# has sel/show on v2, sel only on t2, sel/show v1 (no sel on t1!)
 
1530
--error ER_VIEW_NO_EXPLAIN
 
1531
explain select * from v2;
 
1532
disconnect test11765687;
 
1533
 
 
1534
#
 
1535
--echo ... as pjotr
 
1536
connect (test11765687,localhost,pjotr,,mysqltest1);
 
1537
connection test11765687;
 
1538
 
 
1539
select * from v2;
 
1540
# has sel/show on v2, sel only on t2, nothing on v1
 
1541
# fail: lacks show on v1
 
1542
--error ER_VIEW_NO_EXPLAIN
 
1543
explain select * from v2;
 
1544
disconnect test11765687;
 
1545
 
 
1546
#
 
1547
--echo ... as quintessa
 
1548
connect (test11765687,localhost,quintessa,,mysqltest1);
 
1549
connection test11765687;
 
1550
 
 
1551
select * from v1; # Should succeed.
 
1552
--error ER_VIEW_NO_EXPLAIN
 
1553
explain select * from v1; # fail: lacks select on t1
 
1554
 
 
1555
disconnect test11765687;
 
1556
 
 
1557
# cleanup
 
1558
 
 
1559
#
 
1560
--echo ... as root again at last: clean-up time!
 
1561
connection root;
 
1562
 
 
1563
drop user alice@localhost;
 
1564
drop user bob@localhost;
 
1565
drop user cecil@localhost;
 
1566
drop user dan@localhost;
 
1567
drop user eugene@localhost;
 
1568
drop user fiona@localhost;
 
1569
drop user greg@localhost;
 
1570
drop user han@localhost;
 
1571
drop user inga@localhost;
 
1572
drop user jamie@localhost;
 
1573
drop user karl@localhost;
 
1574
drop user lena@localhost;
 
1575
drop user mhairi@localhost;
 
1576
drop user noam@localhost;
 
1577
drop user olga@localhost;
 
1578
drop user pjotr@localhost;
 
1579
drop user quintessa@localhost;
 
1580
 
 
1581
drop database mysqltest1;
 
1582
 
 
1583
disconnect root;
 
1584
 
 
1585
connection default;
 
1586
 
1186
1587
--echo End of 5.0 tests.
 
1588
 
 
1589
 
 
1590
 
 
1591
# Wait till we reached the initial number of concurrent sessions
 
1592
--source include/wait_until_count_sessions.inc