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

« back to all changes in this revision

Viewing changes to mysql-test/t/grant.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:
3
3
# Grant tests not performed with embedded server
4
4
-- source include/not_embedded.inc
5
5
 
 
6
# Save the initial number of concurrent sessions
 
7
--source include/count_sessions.inc
 
8
 
 
9
SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators;
6
10
SET GLOBAL log_bin_trust_function_creators = 1;
7
11
 
8
12
# Cleanup
80
84
delete from mysql.tables_priv where user='mysqltest_1';
81
85
delete from mysql.columns_priv where user='mysqltest_1';
82
86
flush privileges;
83
 
--error 1141
 
87
--error ER_NONEXISTING_GRANT
84
88
show grants for mysqltest_1@localhost;
85
89
 
86
90
#
118
122
#
119
123
# Test some error conditions
120
124
#
121
 
--error  1221
 
125
--error ER_WRONG_USAGE
122
126
GRANT FILE on mysqltest.*  to mysqltest_1@localhost;
123
 
select 1;       # To test that the previous command didn't cause problems
 
127
select 1;     # To test that the previous command didn't cause problems
124
128
 
125
129
#
126
 
# Bug #4898: User privileges depending on ORDER BY Settings of table db
 
130
# Bug#4898 User privileges depending on ORDER BY Settings of table db
127
131
#
128
132
insert into mysql.user (host, user) values ('localhost', 'test11');
129
 
insert into mysql.db (host, db, user, select_priv) values 
 
133
insert into mysql.db (host, db, user, select_priv) values
130
134
('localhost', 'a%', 'test11', 'Y'), ('localhost', 'ab%', 'test11', 'Y');
131
135
alter table mysql.db order by db asc;
132
136
flush privileges;
138
142
delete from mysql.db where user='test11';
139
143
 
140
144
#
141
 
# Bug#6123: GRANT USAGE inserts useless Db row
 
145
# Bug#6123 GRANT USAGE inserts useless Db row
142
146
#
143
147
create database mysqltest1;
144
148
grant usage on mysqltest1.* to test6123 identified by 'magic123';
147
151
drop database mysqltest1;
148
152
 
149
153
#
150
 
# Test for 'drop user', 'revoke privileges, grant' 
 
154
# Test for 'drop user', 'revoke privileges, grant'
151
155
#
152
156
 
153
157
create table t1 (a int);
162
166
show grants for drop_user@localhost;
163
167
 
164
168
#
165
 
# Bug3086
 
169
# Bug#3086 SHOW GRANTS doesn't follow ANSI_QUOTES
166
170
#
167
171
set sql_mode=ansi_quotes;
168
172
show grants for drop_user@localhost;
180
184
revoke all privileges, grant option from drop_user@localhost;
181
185
show grants for drop_user@localhost;
182
186
drop user drop_user@localhost;
183
 
--error 1269
 
187
--error ER_REVOKE_GRANTS
184
188
revoke all privileges, grant option from drop_user@localhost;
185
189
 
186
190
grant select(a) on test.t1 to drop_user1@localhost;
190
194
# Drop user now implicitly revokes all privileges.
191
195
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
192
196
drop_user4@localhost;
193
 
--error 1269
 
197
--error ER_REVOKE_GRANTS
194
198
revoke all privileges, grant option from drop_user1@localhost, drop_user2@localhost,
195
199
drop_user3@localhost, drop_user4@localhost;
196
 
--error 1396
 
200
--error ER_CANNOT_USER
197
201
drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
198
202
drop_user4@localhost;
199
203
drop table t1;
203
207
drop user mysqltest_1@localhost;
204
208
 
205
209
#
206
 
# Bug #3403 Wrong encodin in SHOW GRANTS output
 
210
# Bug#3403 Wrong encoding in SHOW GRANTS output
207
211
#
208
212
SET NAMES koi8r;
209
213
CREATE DATABASE ��;
210
214
USE ��;
211
 
CREATE TABLE ��� (��� int);
 
215
CREATE TABLE ��� (��� INT);
212
216
 
213
217
GRANT SELECT ON ��.* TO ����@localhost;
214
218
SHOW GRANTS FOR ����@localhost;
229
233
SET NAMES latin1;
230
234
 
231
235
#
232
 
# Bug #5831: REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything
 
236
# Bug#5831 REVOKE ALL PRIVILEGES, GRANT OPTION does not revoke everything
233
237
#
234
238
USE test;
235
239
CREATE TABLE t1 (a int );
298
302
DROP DATABASE testdb10;
299
303
 
300
304
#
301
 
# Bug #6932: a problem with 'revoke ALL PRIVILEGES'
 
305
# Bug#6932 a problem with 'revoke ALL PRIVILEGES'
302
306
#
303
307
 
304
308
create table t1(a int, b int, c int, d int);
312
316
drop table t1;
313
317
 
314
318
#
315
 
# Bug#7391: Cross-database multi-table UPDATE security problem
 
319
# Bug#7391 Cross-database multi-table UPDATE security problem
316
320
#
317
321
create database mysqltest_1;
318
322
create database mysqltest_2;
321
325
create table mysqltest_2.t1 select 1 c, 2 s;
322
326
create table mysqltest_2.t2 select 1 d, 2 t;
323
327
 
324
 
#test the column privileges
 
328
# test the column privileges
325
329
grant update (a) on mysqltest_1.t1 to mysqltest_3@localhost;
326
330
grant select (b) on mysqltest_1.t2 to mysqltest_3@localhost;
327
331
grant select (c) on mysqltest_2.t1 to mysqltest_3@localhost;
328
332
grant update (d) on mysqltest_2.t2 to mysqltest_3@localhost;
329
333
connect (conn1,localhost,mysqltest_3,,);
330
334
connection conn1;
331
 
SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES 
332
 
 WHERE GRANTEE = '''mysqltest_3''@''localhost''' 
 
335
SELECT * FROM INFORMATION_SCHEMA.COLUMN_PRIVILEGES
 
336
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
333
337
 ORDER BY TABLE_NAME,COLUMN_NAME,PRIVILEGE_TYPE;
334
338
SELECT * FROM INFORMATION_SCHEMA.TABLE_PRIVILEGES
335
 
 WHERE GRANTEE = '''mysqltest_3''@''localhost''' 
 
339
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
336
340
 ORDER BY TABLE_NAME,PRIVILEGE_TYPE;
337
341
SELECT * from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES
338
 
 WHERE GRANTEE = '''mysqltest_3''@''localhost''' 
 
342
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
339
343
 ORDER BY TABLE_SCHEMA,PRIVILEGE_TYPE;
340
344
SELECT * from INFORMATION_SCHEMA.USER_PRIVILEGES
341
345
 WHERE GRANTEE = '''mysqltest_3''@''localhost'''
342
346
 ORDER BY TABLE_CATALOG,PRIVILEGE_TYPE;
343
 
--error 1143
 
347
--error ER_COLUMNACCESS_DENIED_ERROR
344
348
update mysqltest_1.t1, mysqltest_1.t2 set q=10 where b=1;
345
 
--error 1143
 
349
--error ER_COLUMNACCESS_DENIED_ERROR
346
350
update mysqltest_1.t2, mysqltest_2.t2 set d=20 where d=1;
347
 
--error 1142
 
351
--error ER_TABLEACCESS_DENIED_ERROR
348
352
update mysqltest_1.t1, mysqltest_2.t2 set d=20 where d=1;
349
 
--error 1142
 
353
--error ER_TABLEACCESS_DENIED_ERROR
350
354
update mysqltest_2.t1, mysqltest_1.t2 set c=20 where b=1;
351
 
--error 1143
 
355
--error ER_COLUMNACCESS_DENIED_ERROR
352
356
update mysqltest_2.t1, mysqltest_2.t2 set d=10 where s=2;
353
 
#the following two should work
 
357
# the following two should work
354
358
update mysqltest_1.t1, mysqltest_2.t2 set a=10,d=10;
355
359
update mysqltest_1.t1, mysqltest_2.t1 set a=20 where c=20;
356
360
connection master;
361
365
revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
362
366
revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
363
367
 
364
 
#test the db/table level privileges
 
368
# test the db/table level privileges
365
369
grant all on mysqltest_2.* to mysqltest_3@localhost;
366
370
grant select on *.* to mysqltest_3@localhost;
367
371
# Next grant is needed to trigger bug#7391. Do not optimize!
373
377
use mysqltest_1;
374
378
update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
375
379
# the following failed before, should fail now.
376
 
--error 1142
 
380
--error ER_TABLEACCESS_DENIED_ERROR
377
381
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
378
382
use mysqltest_2;
379
 
#the following used to succeed, it must fail now.
380
 
--error 1142
 
383
# the following used to succeed, it must fail now.
 
384
--error ER_TABLEACCESS_DENIED_ERROR
381
385
update mysqltest_1.t1, mysqltest_1.t2 set a=100,b=200;
382
 
--error 1142
 
386
--error ER_TABLEACCESS_DENIED_ERROR
383
387
update mysqltest_2.t1, mysqltest_1.t2 set c=100,b=200;
384
 
--error 1142
 
388
--error ER_TABLEACCESS_DENIED_ERROR
385
389
update mysqltest_1.t1, mysqltest_2.t2 set a=100,d=200;
386
 
#lets see the result
 
390
# lets see the result
387
391
connection master;
388
392
select t1.*,t2.* from mysqltest_1.t1,mysqltest_1.t2;
389
393
select t1.*,t2.* from mysqltest_2.t1,mysqltest_2.t2;
395
399
flush privileges;
396
400
drop database mysqltest_1;
397
401
drop database mysqltest_2;
 
402
disconnect conn2;
398
403
 
399
404
#
400
405
# just SHOW PRIVILEGES test
402
407
SHOW PRIVILEGES;
403
408
 
404
409
#
405
 
# Rights for renaming test (Bug #3270)
 
410
# Rights for renaming test (Bug#3270)
406
411
#
407
412
connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
408
413
connection root;
413
418
grant all on mysqltest.t1 to mysqltest_1@localhost;
414
419
connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
415
420
connection user1;
 
421
-- error ER_TABLEACCESS_DENIED_ERROR
416
422
alter table t1 rename t2;
417
423
disconnect user1;
418
424
connection root;
419
425
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
420
426
delete from mysql.user where user=_binary'mysqltest_1';
421
427
drop database mysqltest;
 
428
connection default;
 
429
disconnect root;
422
430
 
423
431
#
424
 
# check all new table priveleges
 
432
# check all new table privileges
425
433
#
426
434
CREATE USER dummy@localhost;
427
435
CREATE DATABASE mysqltest;
487
494
DROP USER dummy@localhost;
488
495
DROP DATABASE mysqltest;
489
496
#
490
 
# Bug #11330: Entry in tables_priv with host = '' causes crash
 
497
# Bug#11330 Entry in tables_priv with host = '' causes crash
491
498
#
492
499
connection default;
493
500
use mysql;
498
505
use test;
499
506
 
500
507
#
501
 
# Bug #10892 user variables not auto cast for comparisons
 
508
# Bug#10892 user variables not auto cast for comparisons
502
509
# Check that we don't get illegal mix of collations
503
510
#
504
511
set @user123="non-existent";
517
524
set names latin1;
518
525
 
519
526
#
520
 
# Bug #15598 Server crashes in specific case during setting new password
 
527
# Bug#15598 Server crashes in specific case during setting new password
521
528
# - Caused by a user with host ''
522
529
#
523
530
create user mysqltest_7@;
524
531
set password for mysqltest_7@ = password('systpass');
525
532
show grants for mysqltest_7@;
526
533
drop user mysqltest_7@;
527
 
--error 1141
 
534
--error ER_NONEXISTING_GRANT
528
535
show grants for mysqltest_7@;
529
536
 
530
537
#
531
 
# Bug#14385: GRANT and mapping to correct user account problems
 
538
# Bug#14385 GRANT and mapping to correct user account problems
532
539
#
533
540
create database mysqltest;
534
541
use mysqltest;
544
551
drop database mysqltest;
545
552
 
546
553
#
547
 
# Bug #27515: DROP previlege is not required for RENAME TABLE
 
554
# Bug#27515 DROP previlege is not required for RENAME TABLE
548
555
#
549
556
connection master;
550
557
create database db27515;
555
562
 
556
563
connect (conn27515, localhost, user27515, , db27515);
557
564
connection conn27515;
558
 
--error 1142
 
565
--error ER_TABLEACCESS_DENIED_ERROR
559
566
rename table t1 to t2;
560
567
disconnect conn27515;
561
568
 
567
574
--echo End of 4.1 tests
568
575
 
569
576
#
570
 
# Bug #16297 In memory grant tables not flushed when users's hostname is ""
 
577
# Bug#16297 In memory grant tables not flushed when users's hostname is ""
571
578
#
572
579
use test;
573
580
create table t1 (a int);
584
591
create user mysqltest_8@host8;
585
592
 
586
593
# Try to create them again
587
 
--error 1396
 
594
--error ER_CANNOT_USER
588
595
create user mysqltest_8@'';
589
 
--error 1396
 
596
--error ER_CANNOT_USER
590
597
create user mysqltest_8;
591
 
--error 1396
 
598
--error ER_CANNOT_USER
592
599
create user mysqltest_8@host8;
593
600
 
594
601
select user, QUOTE(host) from mysql.user where user="mysqltest_8";
683
690
show grants for mysqltest_8@'';
684
691
show grants for mysqltest_8;
685
692
drop user mysqltest_8@'';
686
 
--error 1141
 
693
--error ER_NONEXISTING_GRANT
687
694
show grants for mysqltest_8@'';
688
695
show grants for mysqltest_8;
689
696
select * from  information_schema.user_privileges
690
697
where grantee like "'mysqltest_8'%";
691
698
drop user mysqltest_8;
692
699
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
693
 
--error 1045
 
700
--error ER_ACCESS_DENIED_ERROR
694
701
connect (conn6,localhost,mysqltest_8,,);
695
702
connection master;
696
 
--error 1141
 
703
--error ER_NONEXISTING_GRANT
697
704
show grants for mysqltest_8;
698
705
drop user mysqltest_8@host8;
699
 
--error 1141
 
706
--error ER_NONEXISTING_GRANT
700
707
show grants for mysqltest_8@host8;
701
708
 
702
709
# Restore the anonymous users.
703
710
insert into mysql.user select * from t2;
704
711
flush privileges;
705
712
drop table t2;
706
 
 
707
713
drop table t1;
708
714
 
709
715
#
710
 
# Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non
711
 
#            privileged view
 
716
# Bug#20214 Incorrect error when user calls SHOW CREATE VIEW on non
 
717
#           privileged view
712
718
#
713
719
 
714
720
connection master;
715
721
 
716
722
CREATE DATABASE mysqltest3;
717
 
use mysqltest3;
 
723
USE mysqltest3;
718
724
 
719
725
CREATE TABLE t_nn (c1 INT);
720
726
CREATE VIEW  v_nn AS SELECT * FROM t_nn;
721
727
 
722
728
CREATE DATABASE mysqltest2;
723
 
use mysqltest2;
 
729
USE mysqltest2;
724
730
 
725
731
CREATE TABLE t_nn (c1 INT);
726
732
CREATE VIEW  v_nn AS SELECT * FROM t_nn;
742
748
--error ER_TABLEACCESS_DENIED_ERROR
743
749
SHOW CREATE TABLE mysqltest2.v_nn;
744
750
 
745
 
 
746
 
 
747
751
# fail because of missing SHOW VIEW
748
752
--error ER_TABLEACCESS_DENIED_ERROR
749
753
SHOW CREATE VIEW  mysqltest2.v_yn;
750
754
--error ER_TABLEACCESS_DENIED_ERROR
751
755
SHOW CREATE TABLE mysqltest2.v_yn;
752
756
 
753
 
 
754
 
 
755
757
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
756
758
SHOW CREATE TABLE mysqltest2.v_ny;
757
759
 
758
760
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
759
761
SHOW CREATE VIEW  mysqltest2.v_ny;
760
762
 
761
 
 
762
 
 
763
763
# fail because of missing (specific or generic) SELECT
764
764
--error ER_TABLEACCESS_DENIED_ERROR
765
765
SHOW CREATE TABLE mysqltest3.t_nn;
768
768
--error ER_TABLEACCESS_DENIED_ERROR
769
769
SHOW CREATE VIEW  mysqltest3.t_nn;
770
770
 
771
 
 
772
 
 
773
771
# fail because of missing missing (specific or generic) SELECT (and SHOW VIEW)
774
772
--error ER_TABLEACCESS_DENIED_ERROR
775
773
SHOW CREATE VIEW  mysqltest3.v_nn;
776
774
--error ER_TABLEACCESS_DENIED_ERROR
777
775
SHOW CREATE TABLE mysqltest3.v_nn;
778
776
 
779
 
 
780
 
 
781
777
# succeed thanks to generic SELECT
782
778
SHOW CREATE TABLE mysqltest2.t_nn;
783
779
 
785
781
--error ER_WRONG_OBJECT
786
782
SHOW CREATE VIEW  mysqltest2.t_nn;
787
783
 
788
 
 
789
 
 
790
784
# succeed, have SELECT and SHOW VIEW
791
785
SHOW CREATE VIEW mysqltest2.v_yy;
792
786
 
793
787
# succeed, have SELECT and SHOW VIEW
794
788
SHOW CREATE TABLE mysqltest2.v_yy;
795
789
 
796
 
 
797
 
 
798
 
#clean-up
 
790
# clean-up
799
791
connection master;
800
792
 
801
793
# succeed, we're root
808
800
--error ER_WRONG_OBJECT
809
801
SHOW CREATE VIEW mysqltest2.t_nn;
810
802
 
811
 
 
812
 
 
813
803
DROP VIEW  mysqltest2.v_nn;
814
804
DROP VIEW  mysqltest2.v_yn;
815
805
DROP VIEW  mysqltest2.v_ny;
816
806
DROP VIEW  mysqltest2.v_yy;
817
 
 
818
807
DROP TABLE mysqltest2.t_nn;
819
 
 
820
808
DROP DATABASE mysqltest2;
821
 
 
822
 
 
823
 
 
824
809
DROP VIEW  mysqltest3.v_nn;
825
810
DROP TABLE mysqltest3.t_nn;
826
 
 
827
811
DROP DATABASE mysqltest3;
828
 
 
 
812
disconnect mysqltest_1;
829
813
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
830
814
DROP USER 'mysqltest_1'@'localhost';
831
815
 
832
816
# restore the original database
833
 
use test;
 
817
USE test;
 
818
connection default;
 
819
disconnect master;
 
820
 
834
821
 
835
822
#
836
 
# Bug #10668: CREATE USER does not enforce username length limit
 
823
# Bug#10668 CREATE USER does not enforce username length limit
837
824
#
838
825
--error ER_WRONG_STRING_LENGTH
839
826
create user mysqltest1_thisisreallytoolong;
840
827
 
841
828
#
842
 
# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
 
829
# Test for Bug#16899 Possible buffer overflow in handling of DEFINER-clause.
843
830
#
844
831
# These checks are intended to ensure that appropriate errors are risen when
845
832
# illegal user name or hostname is specified in user-clause of GRANT/REVOKE
847
834
#
848
835
 
849
836
#
850
 
# Bug #22369: Alter table rename combined with other alterations causes lost tables
 
837
# Bug#22369 Alter table rename combined with other alterations causes lost tables
851
838
#
852
839
CREATE DATABASE mysqltest1;
853
840
CREATE TABLE mysqltest1.t1 (
967
954
 
968
955
 
969
956
#
970
 
# BUG#23556: TRUNCATE TABLE still maps to DELETE
 
957
# Bug#23556 TRUNCATE TABLE still maps to DELETE
971
958
#
972
959
CREATE USER bug23556@localhost;
973
960
CREATE DATABASE bug23556;
999
986
USE test;
1000
987
DROP DATABASE bug23556;
1001
988
DROP USER bug23556@localhost;
 
989
connection default;
 
990
disconnect bug23556;
 
991
 
 
992
 
1002
993
#
1003
 
# Bug #6774: Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES
 
994
# Bug#6774 Replication fails with Wrong usage of DB GRANT and GLOBAL PRIVILEGES
1004
995
#
1005
996
# Check if GRANT ... ON * ... fails when no database is selected
1006
997
connect (con1, localhost, root,,*NO-ONE*);
1012
1003
 
1013
1004
 
1014
1005
#
1015
 
# BUG#9504: Stored procedures: execute privilege doesn't make 'use database'
 
1006
# Bug#9504 Stored procedures: execute privilege doesn't make 'use database'
1016
1007
# okay.
1017
1008
#
1018
1009
 
1037
1028
  SELECT 1;
1038
1029
 
1039
1030
CREATE FUNCTION mysqltest3.f_def() RETURNS INT SQL SECURITY DEFINER
1040
 
  RETURN 1;                                                        
1041
 
                                                                   
 
1031
  RETURN 1;
 
1032
 
1042
1033
CREATE FUNCTION mysqltest4.f_inv() RETURNS INT SQL SECURITY INVOKER
1043
1034
  RETURN 1;
1044
1035
 
1094
1085
 
1095
1086
 
1096
1087
#
1097
 
# BUG#27337: Privileges are not restored properly.
 
1088
# Bug#27337 Privileges are not restored properly.
1098
1089
#
1099
1090
# Actually, the patch for this bugs fixes two problems. So, here are two test
1100
1091
# cases.
1156
1147
 
1157
1148
DROP USER mysqltest_1@localhost;
1158
1149
 
1159
 
# Test case 2: priveleges are not checked properly for prepared statements.
 
1150
# Test case 2: privileges are not checked properly for prepared statements.
1160
1151
 
1161
1152
# Prepare.
1162
1153
 
1229
1220
--echo
1230
1221
--echo ---> connection: default
1231
1222
 
 
1223
--disconnect bug27337_con1
1232
1224
--disconnect bug27337_con2
1233
1225
 
1234
1226
DROP DATABASE mysqltest1;
1238
1230
DROP USER mysqltest_2@localhost;
1239
1231
 
1240
1232
#
1241
 
# Bug#27878: Unchecked privileges on a view referring to a table from another 
1242
 
#            database.
 
1233
# Bug#27878 Unchecked privileges on a view referring to a table from another
 
1234
#           database.
1243
1235
#
1244
 
use test;
 
1236
USE test;
1245
1237
CREATE TABLE t1 (f1 int, f2 int);
1246
1238
INSERT INTO t1 VALUES(1,1), (2,2);
1247
1239
CREATE DATABASE db27878;
1248
1240
GRANT UPDATE(f1) ON t1 TO 'mysqltest_1'@'localhost';
1249
1241
GRANT SELECT ON `test`.* TO 'mysqltest_1'@'localhost';
1250
1242
GRANT ALL ON db27878.* TO 'mysqltest_1'@'localhost';
1251
 
use db27878;
 
1243
USE db27878;
1252
1244
CREATE SQL SECURITY INVOKER VIEW db27878.v1 AS SELECT * FROM test.t1;
1253
1245
connect (user1,localhost,mysqltest_1,,test);
1254
1246
connection user1;
1255
 
use db27878;
 
1247
USE db27878;
1256
1248
--error 1356
1257
1249
UPDATE v1 SET f2 = 4;
1258
1250
SELECT * FROM test.t1;
1263
1255
REVOKE ALL ON db27878.* FROM 'mysqltest_1'@'localhost';
1264
1256
DROP USER mysqltest_1@localhost;
1265
1257
DROP DATABASE db27878;
1266
 
use test;
 
1258
USE test;
1267
1259
DROP TABLE t1;
1268
1260
 
1269
1261
--echo #
1272
1264
CREATE TEMPORARY TABLE mysql.user (id INT);
1273
1265
FLUSH PRIVILEGES;
1274
1266
DROP TABLE mysql.user;
 
1267
 
 
1268
 
1275
1269
#
1276
 
# Bug #33201 Crash occurs when granting update privilege on one column of a view
 
1270
# Bug#33201 Crash occurs when granting update privilege on one column of a view
1277
1271
#
1278
1272
drop table if exists test;
1279
1273
drop function if exists test_function;
1304
1298
--echo End of 5.0 tests
1305
1299
 
1306
1300
#
1307
 
# Bug#21432: Database/Table name limited to 64 bytes, not chars, problems with multi-byte
 
1301
# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte
1308
1302
#
1309
1303
set names utf8;
1310
1304
grant select on test.* to юзер_юзер@localhost;
1316
1310
set names default;
1317
1311
 
1318
1312
#
1319
 
# Bug #20901 - CREATE privilege is enough to insert into a table
 
1313
# Bug#20901 CREATE privilege is enough to insert into a table
1320
1314
#
1321
1315
 
1322
1316
create database mysqltest;
1328
1322
connect (user1,localhost,mysqltest,,mysqltest);
1329
1323
connection user1;
1330
1324
# show we don't have INSERT
1331
 
--error 1142
 
1325
--error ER_TABLEACCESS_DENIED_ERROR
1332
1326
insert into t1 values (1);
1333
1327
# show we have CREATE
1334
1328
create table t2 (i INT);
1347
1341
 
1348
1342
 
1349
1343
# CREATE IF NOT EXISTS...SELECT, t1 exists, no INSERT, must fail
1350
 
--error 1142
 
1344
--error ER_TABLEACCESS_DENIED_ERROR
1351
1345
create table if not exists t1 select * from t2;
1352
1346
 
1353
1347
# CREATE IF NOT EXISTS...SELECT, no t3 yet, no INSERT, must fail
1354
 
--error 1142
 
1348
--error ER_TABLEACCESS_DENIED_ERROR
1355
1349
create table if not exists t3 select * from t2;
1356
1350
 
1357
1351
# CREATE IF NOT EXISTS...SELECT, t4 exists, have INSERT, must succeed
1365
1359
create table t6 select * from t2;
1366
1360
 
1367
1361
# CREATE...SELECT, no t7 yet, no INSERT, must fail
1368
 
--error 1142
 
1362
--error ER_TABLEACCESS_DENIED_ERROR
1369
1363
create table t7 select * from t2;
1370
1364
 
1371
1365
# CREATE...SELECT, t4 exists, have INSERT, must still fail (exists)
1373
1367
create table t4 select * from t2;
1374
1368
 
1375
1369
# CREATE...SELECT, t1 exists, no INSERT, must fail
1376
 
--error 1142
 
1370
--error ER_TABLEACCESS_DENIED_ERROR
1377
1371
create table t1 select * from t2;
1378
1372
 
1379
1373
 
1393
1387
 
1394
1388
 
1395
1389
#
1396
 
# Bug #16470 crash on grant if old grant tables
 
1390
# Bug#16470 crash on grant if old grant tables
1397
1391
#
1398
1392
--echo FLUSH PRIVILEGES without procs_priv table.
1399
1393
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
1414
1408
 
1415
1409
 
1416
1410
#
1417
 
# Bug#33464: DROP FUNCTION caused a crash.
 
1411
# Bug#33464 DROP FUNCTION caused a crash.
1418
1412
#
1419
1413
CREATE DATABASE dbbug33464;
1420
1414
CREATE USER 'userbug33464'@'localhost';
1471
1465
--error 0, ER_CANNOT_USER
1472
1466
DROP USER 'userbug33464'@'localhost';
1473
1467
 
1474
 
use test;
 
1468
USE test;
1475
1469
DROP DATABASE dbbug33464;
1476
1470
 
1477
1471
 
1478
 
--echo End of 5.1 tests
 
1472
SET @@global.log_bin_trust_function_creators= @old_log_bin_trust_function_creators;
 
1473
 
 
1474
# Wait till we reached the initial number of concurrent sessions
 
1475
--source include/wait_until_count_sessions.inc