Commit c4ebf87f authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-32984 Update federated table and column privileges

mark auto-inc columns for read/write on INSERT,
but only for read on UPDATE
parent c9902a20
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;
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 ...@@ -7103,7 +7103,7 @@ Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability
indexed and it cannot have a DEFAULT value). indexed and it cannot have a DEFAULT value).
*/ */
m_table->auto_increment_field_not_null= FALSE; m_table->auto_increment_field_not_null= FALSE;
m_table->mark_auto_increment_column(); m_table->mark_auto_increment_column(true);
} }
return error; return error;
......
...@@ -7320,7 +7320,7 @@ inline void TABLE::mark_index_columns_for_read(uint index) ...@@ -7320,7 +7320,7 @@ inline void TABLE::mark_index_columns_for_read(uint index)
always set and sometimes read. 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); DBUG_ASSERT(found_next_number_field);
/* /*
...@@ -7328,7 +7328,8 @@ void TABLE::mark_auto_increment_column() ...@@ -7328,7 +7328,8 @@ void TABLE::mark_auto_increment_column()
store() to check overflow of auto_increment values store() to check overflow of auto_increment values
*/ */
bitmap_set_bit(read_set, found_next_number_field->field_index); 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) if (s->next_number_keypart)
mark_index_columns_for_read(s->next_number_index); mark_index_columns_for_read(s->next_number_index);
file->column_bitmaps_signal(); file->column_bitmaps_signal();
...@@ -7453,7 +7454,7 @@ void TABLE::mark_columns_needed_for_update() ...@@ -7453,7 +7454,7 @@ void TABLE::mark_columns_needed_for_update()
else else
{ {
if (found_next_number_field) 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) if (file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_DELETE)
...@@ -7527,7 +7528,7 @@ void TABLE::mark_columns_needed_for_insert() ...@@ -7527,7 +7528,7 @@ void TABLE::mark_columns_needed_for_insert()
triggers->mark_fields_used(TRG_EVENT_INSERT); triggers->mark_fields_used(TRG_EVENT_INSERT);
} }
if (found_next_number_field) if (found_next_number_field)
mark_auto_increment_column(); mark_auto_increment_column(true);
if (default_field) if (default_field)
mark_default_fields_for_write(TRUE); mark_default_fields_for_write(TRUE);
/* Mark virtual columns for insert */ /* Mark virtual columns for insert */
......
...@@ -1585,7 +1585,7 @@ struct TABLE ...@@ -1585,7 +1585,7 @@ struct TABLE
void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap); void mark_index_columns_no_reset(uint index, MY_BITMAP *bitmap);
void mark_index_columns_for_read(uint index); void mark_index_columns_for_read(uint index);
void restore_column_maps_after_keyread(MY_BITMAP *backup); 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_update(void);
void mark_columns_needed_for_delete(void); void mark_columns_needed_for_delete(void);
void mark_columns_needed_for_insert(void); void mark_columns_needed_for_insert(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment