mirror of
https://github.com/MariaDB/server.git
synced 2025-11-05 01:43:31 +03:00
Merge branch '11.8' into 12.0
main/statistics_json.result is updated forf8ba5ced55(MDEV-36099) The test uses 'delete from t1' in many places and then populates the table again. The natural order of rows in a MyISAM table is well defined and the test was implicitly relying on that. beforef8ba5ced55delete was deleting rows one by one, using ha_myisam::delete_row() because the connection was stuck in rbr mode. This caused rows to be shown in the reverse insertion order (because of the delete link list). MDEV-36099 fixes this bug and the server now correctly uses ha_myisam::delete_all_rows(). This makes rows to be shown in the insertion order as expected.
This commit is contained in:
@@ -292,6 +292,25 @@ a b
|
||||
10 j
|
||||
DROP TABLE t1;
|
||||
DROP SEQUENCE s1;
|
||||
#
|
||||
# End of 10.3 tests
|
||||
# in UPDATE
|
||||
create sequence s1 cache 0;
|
||||
create table t1 (id int unsigned default nextval(s1));
|
||||
insert t1 values ();
|
||||
update t1 set id=default;
|
||||
prepare stmt from "update t1 set id=?";
|
||||
execute stmt using default;
|
||||
deallocate prepare stmt;
|
||||
drop table t1;
|
||||
drop sequence s1;
|
||||
#
|
||||
# MDEV-37302 Assertion failure in Table_triggers_list::add_tables_and_routines_for_triggers upon attempt to insert DEFAULT into non-insertable view
|
||||
#
|
||||
create table t1 (f int);
|
||||
create algorithm=temptable view v1 as select * from t1;
|
||||
create trigger tr before update on t1 for each row set @a=1;
|
||||
insert v1 values (default);
|
||||
ERROR HY000: The target table v1 of the INSERT is not insertable-into
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
# End of 10.6 tests
|
||||
|
||||
@@ -216,6 +216,28 @@ SELECT a, b FROM t1;
|
||||
DROP TABLE t1;
|
||||
DROP SEQUENCE s1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.3 tests
|
||||
|
||||
--echo # in UPDATE
|
||||
create sequence s1 cache 0;
|
||||
create table t1 (id int unsigned default nextval(s1));
|
||||
insert t1 values ();
|
||||
update t1 set id=default;
|
||||
prepare stmt from "update t1 set id=?";
|
||||
execute stmt using default;
|
||||
deallocate prepare stmt;
|
||||
drop table t1;
|
||||
drop sequence s1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-37302 Assertion failure in Table_triggers_list::add_tables_and_routines_for_triggers upon attempt to insert DEFAULT into non-insertable view
|
||||
--echo #
|
||||
create table t1 (f int);
|
||||
create algorithm=temptable view v1 as select * from t1;
|
||||
create trigger tr before update on t1 for each row set @a=1;
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
insert v1 values (default);
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
@@ -97,7 +97,92 @@ ERROR 42000: SELECT, INSERT command denied to user 'u'@'localhost' for table `my
|
||||
disconnect con1;
|
||||
connection default;
|
||||
drop user u;
|
||||
create user u_alter;
|
||||
create table t1 (id int);
|
||||
grant alter on t1 to u_alter;
|
||||
connect con_alter,localhost,u_alter,,mysqltest_1;
|
||||
alter table t1 modify id int default nextval(s1);
|
||||
ERROR 42000: SELECT, INSERT command denied to user 'u_alter'@'localhost' for table `mysqltest_1`.`s1`
|
||||
connection default;
|
||||
grant insert, select on s1 to u_alter;
|
||||
connection con_alter;
|
||||
alter table t1 modify id int default nextval(s1);
|
||||
disconnect con_alter;
|
||||
connection default;
|
||||
drop user u_alter;
|
||||
drop database mysqltest_1;
|
||||
#
|
||||
# End of 10.11 tests
|
||||
# MDEV-36870 Spurious unrelated permission error when selecting from table with default that uses nextval(sequence)
|
||||
#
|
||||
create database db1;
|
||||
use db1;
|
||||
create sequence s1 cache 0;
|
||||
create table t1 (id int unsigned default (10+nextval(s1)));
|
||||
insert t1 values ();
|
||||
create table t2 (id int unsigned default nextval(s1), b int default(default(id)));
|
||||
insert t2 values ();
|
||||
create function f1(x int) returns int sql security invoker
|
||||
begin
|
||||
select id+x into x from t1;
|
||||
return x;
|
||||
insert t1 values ();
|
||||
end|
|
||||
create user u1@localhost;
|
||||
grant select on db1.* to u1@localhost;
|
||||
grant execute on db1.* to u1@localhost;
|
||||
grant all privileges on test.* to u1@localhost;
|
||||
use test;
|
||||
create table t3 (id int unsigned default (20+nextval(db1.s1)), b int);
|
||||
insert t3 values ();
|
||||
create sequence s2 cache 0;
|
||||
create table t4 (id int unsigned default (10+nextval(s2)), b int);
|
||||
insert t4 values ();
|
||||
connect u1,localhost,u1,,db1;
|
||||
select * from t1;
|
||||
id
|
||||
11
|
||||
connection default;
|
||||
flush tables;
|
||||
connection u1;
|
||||
select * from t1;
|
||||
id
|
||||
11
|
||||
select default(id) from t1;
|
||||
ERROR 42000: INSERT command denied to user 'u1'@'localhost' for table `db1`.`s1`
|
||||
select * from t2;
|
||||
id b
|
||||
2 3
|
||||
select f1(100);
|
||||
f1(100)
|
||||
111
|
||||
select column_name, data_type, column_default from information_schema.columns where table_schema='db1' and table_name='t1';
|
||||
column_name data_type column_default
|
||||
id int (10 + nextval(`db1`.`s1`))
|
||||
use test;
|
||||
insert t3 values ();
|
||||
ERROR 42000: INSERT command denied to user 'u1'@'localhost' for table `db1`.`s1`
|
||||
insert t4 values ();
|
||||
insert t3 (b) select 5;
|
||||
ERROR 42000: INSERT command denied to user 'u1'@'localhost' for table `db1`.`s1`
|
||||
insert t4 (b) select 5;
|
||||
update t3 set id=default;
|
||||
ERROR 42000: INSERT command denied to user 'u1'@'localhost' for table `db1`.`s1`
|
||||
update t4 set id=default;
|
||||
prepare stmt from "update t3 set id=?";
|
||||
execute stmt using default;
|
||||
ERROR 42000: INSERT command denied to user 'u1'@'localhost' for table `db1`.`s1`
|
||||
prepare stmt from "update t4 set id=?";
|
||||
execute stmt using default;
|
||||
deallocate prepare stmt;
|
||||
insert t4 (b) values ((select * from db1.t1));
|
||||
insert t4 (b) values ((select default(id) from db1.t1));
|
||||
ERROR 42000: INSERT command denied to user 'u1'@'localhost' for table `db1`.`s1`
|
||||
connection default;
|
||||
disconnect u1;
|
||||
select nextval(db1.s1) as 'must be 5';
|
||||
must be 5
|
||||
5
|
||||
drop user u1@localhost;
|
||||
drop database db1;
|
||||
drop table t3, t4, s2;
|
||||
# End of 10.6 tests
|
||||
|
||||
@@ -106,12 +106,121 @@ create table t1 (a int not null default(nextval(s1)),
|
||||
--connection default
|
||||
drop user u;
|
||||
|
||||
#
|
||||
# Cleanup
|
||||
#
|
||||
|
||||
# ALTER for table with DEFAULT NEXTVAL(seq) column needs INSERT/SELECT on seq
|
||||
# just like CREATE does in the example above
|
||||
create user u_alter;
|
||||
create table t1 (id int);
|
||||
grant alter on t1 to u_alter;
|
||||
--connect(con_alter,localhost,u_alter,,mysqltest_1)
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
alter table t1 modify id int default nextval(s1);
|
||||
--connection default
|
||||
grant insert, select on s1 to u_alter;
|
||||
--connection con_alter
|
||||
alter table t1 modify id int default nextval(s1);
|
||||
--disconnect con_alter
|
||||
--connection default
|
||||
drop user u_alter;
|
||||
drop database mysqltest_1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.11 tests
|
||||
--echo # MDEV-36870 Spurious unrelated permission error when selecting from table with default that uses nextval(sequence)
|
||||
--echo #
|
||||
|
||||
# various tests for permission checking on sequences
|
||||
create database db1;
|
||||
use db1;
|
||||
create sequence s1 cache 0;
|
||||
create table t1 (id int unsigned default (10+nextval(s1)));
|
||||
insert t1 values ();
|
||||
|
||||
create table t2 (id int unsigned default nextval(s1), b int default(default(id)));
|
||||
insert t2 values ();
|
||||
|
||||
# INSERT affects prelocking, but is never actually executed
|
||||
delimiter |;
|
||||
create function f1(x int) returns int sql security invoker
|
||||
begin
|
||||
select id+x into x from t1;
|
||||
return x;
|
||||
insert t1 values ();
|
||||
end|
|
||||
delimiter ;|
|
||||
|
||||
create user u1@localhost;
|
||||
grant select on db1.* to u1@localhost;
|
||||
grant execute on db1.* to u1@localhost;
|
||||
grant all privileges on test.* to u1@localhost;
|
||||
|
||||
use test;
|
||||
create table t3 (id int unsigned default (20+nextval(db1.s1)), b int);
|
||||
insert t3 values ();
|
||||
|
||||
create sequence s2 cache 0;
|
||||
create table t4 (id int unsigned default (10+nextval(s2)), b int);
|
||||
insert t4 values ();
|
||||
|
||||
connect u1,localhost,u1,,db1;
|
||||
|
||||
# table already in the cache. must be re-fixed
|
||||
# SELECT * - no error
|
||||
select * from t1;
|
||||
|
||||
# not in cache
|
||||
connection default;
|
||||
flush tables;
|
||||
connection u1;
|
||||
# SELECT * - no error
|
||||
select * from t1;
|
||||
|
||||
# SELECT DEFAULT() - error
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
select default(id) from t1;
|
||||
|
||||
# default(default(nextval))
|
||||
select * from t2;
|
||||
|
||||
# SELECT but table has TL_WRITE because of prelocking
|
||||
select f1(100);
|
||||
|
||||
# opening the table for I_S
|
||||
select column_name, data_type, column_default from information_schema.columns where table_schema='db1' and table_name='t1';
|
||||
|
||||
use test;
|
||||
# insert
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
insert t3 values ();
|
||||
insert t4 values ();
|
||||
#insert select
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
insert t3 (b) select 5;
|
||||
insert t4 (b) select 5;
|
||||
#update
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
update t3 set id=default;
|
||||
update t4 set id=default;
|
||||
|
||||
# PS UPDATE with ? = DEFAULT
|
||||
prepare stmt from "update t3 set id=?";
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
execute stmt using default;
|
||||
prepare stmt from "update t4 set id=?";
|
||||
execute stmt using default;
|
||||
deallocate prepare stmt;
|
||||
|
||||
# SELECT * in a subquery, like INSERT t3 VALUES ((SELECT * FROM t1));
|
||||
# with sequences both on t3 and t1
|
||||
insert t4 (b) values ((select * from db1.t1));
|
||||
--error ER_TABLEACCESS_DENIED_ERROR
|
||||
insert t4 (b) values ((select default(id) from db1.t1));
|
||||
|
||||
connection default;
|
||||
disconnect u1;
|
||||
--disable_ps2_protocol
|
||||
select nextval(db1.s1) as 'must be 5';
|
||||
--enable_ps2_protocol
|
||||
drop user u1@localhost;
|
||||
drop database db1;
|
||||
drop table t3, t4, s2;
|
||||
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
Reference in New Issue
Block a user