Commit 6625fad8 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-4564 ALTER on a temporary table generates an audit event

parent 3bc814be
...@@ -44,6 +44,7 @@ insert t2 values ('2020-10-09'); ...@@ -44,6 +44,7 @@ insert t2 values ('2020-10-09');
select * from t2; select * from t2;
a a
2020-10-09 2020-10-09
alter table t2 add column b int;
drop table t2; drop table t2;
explain select distinct * from t2; explain select distinct * from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -77,8 +78,8 @@ root[root] @ localhost [] test.t1 : read ...@@ -77,8 +78,8 @@ root[root] @ localhost [] test.t1 : read
root[root] @ localhost [] >> rename table t1 to t2 root[root] @ localhost [] >> rename table t1 to t2
root[root] @ localhost [] test.t1 : rename to test.t2 root[root] @ localhost [] test.t1 : rename to test.t2
root[root] @ localhost [] >> alter table t2 add column b int root[root] @ localhost [] >> alter table t2 add column b int
root[root] @ localhost [] test.t2 : alter
root[root] @ localhost [] test.t2 : read root[root] @ localhost [] test.t2 : read
root[root] @ localhost [] test.t2 : alter
root[root] @ localhost [] >> create definer=testuser@localhost view v1 as select t2.a+1, t2_copy.a+2 from t2, t2 as t2_copy root[root] @ localhost [] >> create definer=testuser@localhost view v1 as select t2.a+1, t2_copy.a+2 from t2, t2 as t2_copy
root[root] @ localhost [] test.t2 : read root[root] @ localhost [] test.t2 : read
root[root] @ localhost [] test.t2 : read root[root] @ localhost [] test.t2 : read
...@@ -89,6 +90,7 @@ root[root] @ localhost [] >> drop view v1 ...@@ -89,6 +90,7 @@ root[root] @ localhost [] >> drop view v1
root[root] @ localhost [] >> create temporary table t2 (a date) root[root] @ localhost [] >> create temporary table t2 (a date)
root[root] @ localhost [] >> insert t2 values ('2020-10-09') root[root] @ localhost [] >> insert t2 values ('2020-10-09')
root[root] @ localhost [] >> select * from t2 root[root] @ localhost [] >> select * from t2
root[root] @ localhost [] >> alter table t2 add column b int
root[root] @ localhost [] >> drop table t2 root[root] @ localhost [] >> drop table t2
root[root] @ localhost [] >> explain select distinct * from t2 root[root] @ localhost [] >> explain select distinct * from t2
root[root] @ localhost [] test.t2 : read root[root] @ localhost [] test.t2 : read
......
...@@ -38,6 +38,7 @@ drop view v1; ...@@ -38,6 +38,7 @@ drop view v1;
create temporary table t2 (a date); create temporary table t2 (a date);
insert t2 values ('2020-10-09'); insert t2 values ('2020-10-09');
select * from t2; select * from t2;
alter table t2 add column b int; # MDEV-4565 ALTER on a temporary table generates an audit event
drop table t2; drop table t2;
# internal temp table generates no audit events # internal temp table generates no audit events
......
...@@ -6064,13 +6064,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -6064,13 +6064,16 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
mysql_ha_rm_tables(thd, table_list); mysql_ha_rm_tables(thd, table_list);
mysql_audit_alter_table(thd, table_list);
/* DISCARD/IMPORT TABLESPACE is always alone in an ALTER TABLE */ /* DISCARD/IMPORT TABLESPACE is always alone in an ALTER TABLE */
if (alter_info->tablespace_op != NO_TABLESPACE_OP) if (alter_info->tablespace_op != NO_TABLESPACE_OP)
{
mysql_audit_alter_table(thd, table_list);
/* Conditionally writes to binlog. */ /* Conditionally writes to binlog. */
DBUG_RETURN(mysql_discard_or_import_tablespace(thd,table_list, bool ret= mysql_discard_or_import_tablespace(thd,table_list,
alter_info->tablespace_op)); alter_info->tablespace_op);
DBUG_RETURN(ret);
}
/* /*
Code below can handle only base tables so ensure that we won't open a view. Code below can handle only base tables so ensure that we won't open a view.
...@@ -6262,6 +6265,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -6262,6 +6265,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
my_error(ER_ILLEGAL_HA, MYF(0), table_name); my_error(ER_ILLEGAL_HA, MYF(0), table_name);
goto err; goto err;
} }
if (table->s->tmp_table == NO_TMP_TABLE)
mysql_audit_alter_table(thd, table_list);
thd_proc_info(thd, "setup"); thd_proc_info(thd, "setup");
if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) && if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) &&
......
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