| 1 |
# |
| 2 |
# Tests that the character set setting is properly picked up by the |
| 3 |
# session that reads the rules table. |
| 4 |
# |
| 5 |
# Query rewrite plugin was installed. |
| 6 |
DELETE FROM query_rewrite.rewrite_rules; |
| 7 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 8 |
VALUES ( 'SELECT * FROM mydb.mytable WHERE mycol = ?', 'select "rule1"' ); |
| 9 |
CALL query_rewrite.flush_rewrite_rules(); |
| 10 |
CREATE DATABASE mydb; |
| 11 |
CREATE TABLE mydb.mytable ( mycol char(3), mycol2 CHAR(100) ); |
| 12 |
INSERT INTO mydb.mytable VALUES ( 'xxx', 'Not supposed to be seeing this.' ); |
| 13 |
SELECT * FROM mydb.mytable WHERE mycol = 'xxx'; |
| 14 |
rule1 |
| 15 |
rule1 |
| 16 |
Warnings: |
| 17 |
Note 1105 Query 'SELECT * FROM mydb.mytable WHERE mycol = 'xxx'' rewritten to 'select "rule1"' by a query rewrite plugin |
| 18 |
DROP DATABASE mydb; |
| 19 |
# We now set the global value of the variable, this should not affect |
| 20 |
# the plugin. It should copy the session value from our session. |
| 21 |
SET @@global.character_set_client = utf8mb4; |
| 22 |
SELECT * FROM mydb.mytable WHERE mycol = 'xxx'; |
| 23 |
rule1 |
| 24 |
rule1 |
| 25 |
Warnings: |
| 26 |
Note 1105 Query 'SELECT * FROM mydb.mytable WHERE mycol = 'xxx'' rewritten to 'select "rule1"' by a query rewrite plugin |
| 27 |
# Regenerating the digests should still work. |
| 28 |
CALL query_rewrite.flush_rewrite_rules(); |
| 29 |
SELECT * FROM mydb.mytable WHERE mycol = 'xxx'; |
| 30 |
rule1 |
| 31 |
rule1 |
| 32 |
Warnings: |
| 33 |
Note 1105 Query 'SELECT * FROM mydb.mytable WHERE mycol = 'xxx'' rewritten to 'select "rule1"' by a query rewrite plugin |
| 34 |
# We now repeat the above test with a character set where the digests |
| 35 |
# are known to differ. If we were lucky the last time, it will show now. |
| 36 |
# The global setting should still be ignored. |
| 37 |
SET @@global.character_set_client = latin1; |
| 38 |
SELECT * FROM mydb.mytable WHERE mycol = 'xxx'; |
| 39 |
rule1 |
| 40 |
rule1 |
| 41 |
Warnings: |
| 42 |
Note 1105 Query 'SELECT * FROM mydb.mytable WHERE mycol = 'xxx'' rewritten to 'select "rule1"' by a query rewrite plugin |
| 43 |
# Regenerating the digests should still work. |
| 44 |
CALL query_rewrite.flush_rewrite_rules(); |
| 45 |
SELECT * FROM mydb.mytable WHERE mycol = 'xxx'; |
| 46 |
rule1 |
| 47 |
rule1 |
| 48 |
Warnings: |
| 49 |
Note 1105 Query 'SELECT * FROM mydb.mytable WHERE mycol = 'xxx'' rewritten to 'select "rule1"' by a query rewrite plugin |
| 50 |
SET @@global.character_set_client = DEFAULT; |
| 51 |
# |
| 52 |
# This is perhaps an unwanted result, but the rules table-reading |
| 53 |
# session can't access our session's setting. |
| 54 |
# |
| 55 |
SET @@session.character_set_client = utf8mb4; |
| 56 |
DELETE FROM query_rewrite.rewrite_rules; |
| 57 |
INSERT INTO query_rewrite.rewrite_rules ( pattern, replacement ) |
| 58 |
VALUES ( 'SELECT * FROM mydb.mytable WHERE mycol = ?', 'select "rule1"' ); |
| 59 |
CALL query_rewrite.flush_rewrite_rules(); |
| 60 |
CREATE DATABASE mydb; |
| 61 |
CREATE TABLE mydb.mytable ( mycol char(3), mycol2 CHAR(100) ); |
| 62 |
INSERT INTO mydb.mytable VALUES ( 'xxx', 'Not supposed to be seeing this.' ); |
| 63 |
SELECT * FROM mydb.mytable WHERE mycol = 'xxx'; |
| 64 |
rule1 |
| 65 |
rule1 |
| 66 |
Warnings: |
| 67 |
Note 1105 Query 'SELECT * FROM mydb.mytable WHERE mycol = 'xxx'' rewritten to 'select "rule1"' by a query rewrite plugin |
| 68 |
DROP DATABASE mydb; |
| 69 |
SET @@session.character_set_client = DEFAULT; |
| 70 |
Warnings: |
| 71 |
Warning 1620 Plugin is busy and will be uninstalled on shutdown |
| 72 |
# Query rewrite plugin was queued for uninstalling. |