mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-32984 Update federated table and column privileges
mark auto-inc columns for read/write on INSERT, but only for read on UPDATE
This commit is contained in:
36
mysql-test/suite/federated/update.result
Normal file
36
mysql-test/suite/federated/update.result
Normal file
@ -0,0 +1,36 @@
|
||||
connect master,127.0.0.1,root,,test,$MASTER_MYPORT,;
|
||||
connect slave,127.0.0.1,root,,test,$SLAVE_MYPORT,;
|
||||
connection master;
|
||||
CREATE DATABASE federated;
|
||||
connection slave;
|
||||
CREATE DATABASE federated;
|
||||
#
|
||||
# MDEV-32984 Update federated table and column privileges
|
||||
#
|
||||
connection slave;
|
||||
create database db1;
|
||||
create user my@localhost identified by '1qaz2wsx';
|
||||
create table db1.t1 (
|
||||
f1 int auto_increment primary key,
|
||||
f2 varchar(50),
|
||||
f3 varchar(50),
|
||||
unique (f2)
|
||||
);
|
||||
grant insert, select (f1, f2, f3), update (f3) on db1.t1 to my@localhost;
|
||||
connection master;
|
||||
create table tt1 engine=federated connection='mysql://my:1qaz2wsx@localhost:$SLAVE_MYPORT/db1/t1';
|
||||
insert into tt1 (f2,f3) values ('test','123');
|
||||
select * from tt1;
|
||||
f1 f2 f3
|
||||
1 test 123
|
||||
update tt1 set f3='123456' where f2='test';
|
||||
drop table tt1;
|
||||
connection slave;
|
||||
drop database db1;
|
||||
drop user my@localhost;
|
||||
connection master;
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
DROP DATABASE IF EXISTS federated;
|
||||
connection slave;
|
||||
DROP TABLE IF EXISTS federated.t1;
|
||||
DROP DATABASE IF EXISTS federated;
|
32
mysql-test/suite/federated/update.test
Normal file
32
mysql-test/suite/federated/update.test
Normal file
@ -0,0 +1,32 @@
|
||||
source include/federated.inc;
|
||||
source have_federatedx.inc;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-32984 Update federated table and column privileges
|
||||
--echo #
|
||||
connection slave;
|
||||
create database db1;
|
||||
create user my@localhost identified by '1qaz2wsx';
|
||||
create table db1.t1 (
|
||||
f1 int auto_increment primary key,
|
||||
f2 varchar(50),
|
||||
f3 varchar(50),
|
||||
unique (f2)
|
||||
);
|
||||
grant insert, select (f1, f2, f3), update (f3) on db1.t1 to my@localhost;
|
||||
|
||||
connection master;
|
||||
evalp create table tt1 engine=federated connection='mysql://my:1qaz2wsx@localhost:$SLAVE_MYPORT/db1/t1';
|
||||
insert into tt1 (f2,f3) values ('test','123');
|
||||
select * from tt1;
|
||||
update tt1 set f3='123456' where f2='test';
|
||||
|
||||
drop table tt1;
|
||||
|
||||
connection slave;
|
||||
drop database db1;
|
||||
drop user my@localhost;
|
||||
|
||||
source include/federated_cleanup.inc;
|
||||
|
||||
|
@ -7103,7 +7103,7 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability
|
||||
indexed and it cannot have a DEFAULT value).
|
||||
*/
|
||||
m_table->auto_increment_field_not_null= FALSE;
|
||||
m_table->mark_auto_increment_column();
|
||||
m_table->mark_auto_increment_column(true);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
@ -7320,7 +7320,7 @@ inline void TABLE::mark_index_columns_for_read(uint index)
|
||||
always set and sometimes read.
|
||||
*/
|
||||
|
||||
void TABLE::mark_auto_increment_column()
|
||||
void TABLE::mark_auto_increment_column(bool is_insert)
|
||||
{
|
||||
DBUG_ASSERT(found_next_number_field);
|
||||
/*
|
||||
@ -7328,7 +7328,8 @@ void TABLE::mark_auto_increment_column()
|
||||
store() to check overflow of auto_increment values
|
||||
*/
|
||||
bitmap_set_bit(read_set, found_next_number_field->field_index);
|
||||
bitmap_set_bit(write_set, found_next_number_field->field_index);
|
||||
if (is_insert)
|
||||
bitmap_set_bit(write_set, found_next_number_field->field_index);
|
||||
if (s->next_number_keypart)
|
||||
mark_index_columns_for_read(s->next_number_index);
|
||||
file->column_bitmaps_signal();
|
||||
@ -7453,7 +7454,7 @@ void TABLE::mark_columns_needed_for_update()
|
||||
else
|
||||
{
|
||||
if (found_next_number_field)
|
||||
mark_auto_increment_column();
|
||||
mark_auto_increment_column(false);
|
||||
}
|
||||
|
||||
if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE)
|
||||
@ -7527,7 +7528,7 @@ void TABLE::mark_columns_needed_for_insert()
|
||||
triggers->mark_fields_used(TRG_EVENT_INSERT);
|
||||
}
|
||||
if (found_next_number_field)
|
||||
mark_auto_increment_column();
|
||||
mark_auto_increment_column(true);
|
||||
if (default_field)
|
||||
mark_default_fields_for_write(TRUE);
|
||||
/* Mark virtual columns for insert */
|
||||
|
@ -1585,7 +1585,7 @@ public:
|
||||
void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap);
|
||||
void mark_index_columns_for_read(uint index);
|
||||
void restore_column_maps_after_keyread(MY_BITMAP *backup);
|
||||
void mark_auto_increment_column(void);
|
||||
void mark_auto_increment_column(bool insert_fl);
|
||||
void mark_columns_needed_for_update(void);
|
||||
void mark_columns_needed_for_delete(void);
|
||||
void mark_columns_needed_for_insert(void);
|
||||
|
Reference in New Issue
Block a user