1
by brian
clean slate |
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
|
|
6 |
drop table t1;
|
|
7 |
drop view v1;
|
|
8 |
CREATE DATABASE meow;
|
|
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
|
|
30 |
FROM table_source
|
|
31 |
INNER JOIN view_stations AS stations
|
|
32 |
ON table_source.id = stations.icao
|
|
33 |
LEFT JOIN table_target AS old
|
|
34 |
USING (mexs_id);
|
|
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
|
|
38 |
FROM table_source
|
|
39 |
INNER JOIN view_stations AS stations
|
|
40 |
ON table_source.id = stations.icao
|
|
41 |
LEFT JOIN view_target2 AS old
|
|
42 |
USING (mexs_id);
|
|
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
|
|
46 |
FROM table_source
|
|
47 |
INNER JOIN view_stations AS stations
|
|
48 |
ON table_source.id = stations.icao
|
|
49 |
LEFT JOIN view_target3 AS old
|
|
50 |
USING (mexs_id);
|
|
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
|
|
57 |
FROM table_source
|
|
58 |
INNER JOIN view_stations AS stations
|
|
59 |
ON table_source.id = stations.icao
|
|
60 |
LEFT JOIN table_target AS old
|
|
61 |
USING (mexs_id);
|
|
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
|
|
66 |
FROM table_source
|
|
67 |
INNER JOIN view_stations AS stations
|
|
68 |
ON table_source.id = stations.icao
|
|
69 |
LEFT JOIN view_target2 AS old
|
|
70 |
USING (mexs_id);
|
|
71 |
mexs_id messzeit
|
|
72 |
87654321 2006-07-12 07:50:00
|
|
73 |
REPLACE INTO view_target2
|
|
74 |
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
|
|
75 |
FROM table_source
|
|
76 |
INNER JOIN view_stations AS stations
|
|
77 |
ON table_source.id = stations.icao
|
|
78 |
LEFT JOIN view_target2 AS old
|
|
79 |
USING (mexs_id);
|
|
80 |
REPLACE INTO view_target3
|
|
81 |
SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
|
|
82 |
FROM table_source
|
|
83 |
INNER JOIN view_stations AS stations
|
|
84 |
ON table_source.id = stations.icao
|
|
85 |
LEFT JOIN view_target3 AS old
|
|
86 |
USING (mexs_id);
|
|
87 |
SELECT * FROM table_target;
|
|
88 |
mexs_id messzeit
|
|
89 |
87654321 2006-07-12 07:50:00
|
|
90 |
SELECT * FROM view_target2;
|
|
91 |
mexs_id messzeit
|
|
92 |
12X45Y78 2006-07-12 07:50:00
|
|
93 |
87654321 2006-07-12 07:50:00
|
|
94 |
SELECT * FROM view_target3;
|
|
95 |
mexs_id messzeit
|
|
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;
|
|
107 |
DROP DATABASE meow;
|
|
108 |
connection: default
|
|
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));
|
|
112 |
lock table t1 read;
|
|
113 |
connection: update
|
|
114 |
set low_priority_updates=1;
|
|
115 |
show variables like 'low_priority_updates';
|
|
116 |
Variable_name Value
|
|
117 |
low_priority_updates ON
|
|
118 |
insert into t1 values (1, 2) ON DUPLICATE KEY UPDATE b = 2;;
|
|
119 |
connection: select
|
|
120 |
select * from t1;
|
|
121 |
a b
|
|
122 |
connection: default
|
|
123 |
select * from t1;
|
|
124 |
a b
|
|
125 |
unlock tables;
|
|
126 |
drop table t1;
|
|
127 |
set low_priority_updates=default;
|