1
drop table if exists t1;
2
create table t1 (n int);
3
create view v1 as select * from t1;
4
insert delayed into v1 values (1);
5
ERROR HY000: 'test.v1' is not BASE TABLE
9
CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
10
CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
11
CREATE TABLE table_target3 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
12
CREATE VIEW view_target2 AS SELECT mexs_id,messzeit FROM table_target2;
13
CREATE SQL SECURITY INVOKER VIEW view_target3 AS SELECT mexs_id,messzeit FROM table_target3;
14
CREATE TABLE table_stations ( mexs_id VARCHAR(8), icao VARCHAR(4), country CHAR(2), PRIMARY KEY (mexs_id), UNIQUE KEY icao (icao), KEY country (country), CONSTRAINT stations_ibfk_8 FOREIGN KEY (country) REFERENCES countries (country) ON UPDATE CASCADE);
15
INSERT INTO table_stations VALUES ('87654321','XXXX','YY');
16
CREATE TABLE table_countries ( country CHAR(2), iso_short_en VARCHAR(64), PRIMARY KEY (country));
17
INSERT INTO table_countries VALUES ('YY','Entenhausen');
18
CREATE ALGORITHM=MERGE SQL SECURITY INVOKER VIEW view_stations AS select table_stations.mexs_id AS mexs_id, table_stations.icao AS icao, table_stations.country AS landescode from (table_stations join table_countries on((table_stations.country = table_countries.country)));
19
CREATE TABLE table_source ( id varchar(4), datetime TIMESTAMP, PRIMARY KEY (id));
20
INSERT INTO table_source VALUES ('XXXX','2006-07-12 07:50:00');
21
GRANT SELECT ON table_source TO user20989@localhost;
22
GRANT SELECT ON table_countries TO user20989@localhost;
23
GRANT SELECT ON table_stations TO user20989@localhost;
24
GRANT SELECT ON view_stations TO user20989@localhost;
25
GRANT SELECT ON table_target TO user20989@localhost;
26
GRANT SELECT ON table_target2 TO user20989@localhost;
27
GRANT INSERT,DELETE,SELECT ON view_target3 TO user20989@localhost;
28
REPLACE INTO table_target
29
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
31
INNER JOIN view_stations AS stations
32
ON table_source.id = stations.icao
33
LEFT JOIN table_target AS old
35
ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'table_target'
36
REPLACE INTO view_target2
37
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
39
INNER JOIN view_stations AS stations
40
ON table_source.id = stations.icao
41
LEFT JOIN view_target2 AS old
43
ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'view_target2'
44
REPLACE INTO view_target3
45
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
47
INNER JOIN view_stations AS stations
48
ON table_source.id = stations.icao
49
LEFT JOIN view_target3 AS old
51
ERROR HY000: View 'meow.view_target3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
52
GRANT INSERT,DELETE ON table_target TO user20989@localhost;
53
GRANT INSERT,DELETE,SELECT ON view_target2 TO user20989@localhost;
54
GRANT INSERT,DELETE,SELECT ON table_target3 TO user20989@localhost;
55
REPLACE INTO table_target
56
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
58
INNER JOIN view_stations AS stations
59
ON table_source.id = stations.icao
60
LEFT JOIN table_target AS old
62
REPLACE INTO table_target2 VALUES ('00X45Y78','2006-07-12 07:50:00');
63
ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'table_target2'
64
REPLACE INTO view_target2 VALUES ('12X45Y78','2006-07-12 07:50:00');
65
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
67
INNER JOIN view_stations AS stations
68
ON table_source.id = stations.icao
69
LEFT JOIN view_target2 AS old
72
87654321 2006-07-12 07:50:00
73
REPLACE INTO view_target2
74
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
76
INNER JOIN view_stations AS stations
77
ON table_source.id = stations.icao
78
LEFT JOIN view_target2 AS old
80
REPLACE INTO view_target3
81
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
83
INNER JOIN view_stations AS stations
84
ON table_source.id = stations.icao
85
LEFT JOIN view_target3 AS old
87
SELECT * FROM table_target;
89
87654321 2006-07-12 07:50:00
90
SELECT * FROM view_target2;
92
12X45Y78 2006-07-12 07:50:00
93
87654321 2006-07-12 07:50:00
94
SELECT * FROM view_target3;
96
87654321 2006-07-12 07:50:00
97
DROP VIEW view_stations;
98
DROP TABLE table_source;
99
DROP TABLE table_countries;
100
DROP TABLE table_stations;
101
DROP TABLE table_target;
102
DROP TABLE table_target2;
103
DROP TABLE table_target3;
104
DROP VIEW view_target2;
105
DROP VIEW view_target3;
106
DROP USER user20989@localhost;
109
set low_priority_updates=1;
110
drop table if exists t1;
111
create table t1 (a int, b int, unique key t1$a (a));
114
set low_priority_updates=1;
115
show variables like 'low_priority_updates';
117
low_priority_updates ON
118
insert into t1 values (1, 2) ON DUPLICATE KEY UPDATE b = 2;;
127
set low_priority_updates=default;