Skip to content

Commit 0cfb868

Browse files
author
Steinar H. Gunderson
committed
WL #10824: Remove query cache [step 11, actual removal]
Remove the query cache and all code related to it. Note that the SQL_NO_CACHE keyword stays, but now does nothing (not even semantic checking that it's not in subqueries). In the process, we set HAVE_QUERY_CACHE to NO, so that interested clients can test for it reliably. NDB code has not been removed but commented out for later cleanup, at the request of the NDB team. Change-Id: I0aa54211dbcccca1f408c01aa91b58e33c39294e
1 parent feaeaff commit 0cfb868

File tree

112 files changed

+221
-7282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+221
-7282
lines changed

client/mysql.cc

-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ static COMMANDS commands[] = {
796796
{ "SQLWARNING", 0, 0, 0, ""},
797797
{ "SQL_BIG_RESULT", 0, 0, 0, ""},
798798
{ "SQL_BUFFER_RESULT", 0, 0, 0, ""},
799-
{ "SQL_CACHE", 0, 0, 0, ""},
800799
{ "SQL_CALC_FOUND_ROWS", 0, 0, 0, ""},
801800
{ "SQL_NO_CACHE", 0, 0, 0, ""},
802801
{ "SQL_SMALL_RESULT", 0, 0, 0, ""},

include/my_base.h

-5
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,4 @@ typedef my_off_t ha_rows;
11361136

11371137
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
11381138

1139-
/* invalidator function reference for Query Cache */
1140-
C_MODE_START
1141-
typedef void (* invalidator_by_filename)(const char * filename);
1142-
C_MODE_END
1143-
11441139
#endif /* _my_base_h */

include/myisammrg.h

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ extern int myrg_create(const char *name, const char **table_names,
115115
extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function,
116116
void *extra_arg);
117117
extern int myrg_reset(MYRG_INFO *info);
118-
extern void myrg_extrafunc(MYRG_INFO *info,invalidator_by_filename inv);
119118
extern ha_rows myrg_records_in_range(MYRG_INFO *info, int inx,
120119
key_range *min_key, key_range *max_key);
121120
extern ha_rows myrg_records(MYRG_INFO *info);

include/mysql.h.pp

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
unsigned char reading_or_writing;
111111
char save_char;
112112
bool compress;
113-
unsigned char *unused;
114113
unsigned int last_errno;
115114
unsigned char error;
116115
char last_error[512];

include/mysql/plugin.h

-13
Original file line numberDiff line numberDiff line change
@@ -713,19 +713,6 @@ unsigned long thd_get_thread_id(const MYSQL_THD thd);
713713
*/
714714
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
715715

716-
/**
717-
Invalidate the query cache for a given table.
718-
719-
@param thd user thread connection handle
720-
@param key databasename/tablename in the canonical format.
721-
@param key_length length of key in bytes, including the PATH separator
722-
@param using_trx flag: TRUE if using transactions, FALSE otherwise
723-
*/
724-
void mysql_query_cache_invalidate4(MYSQL_THD thd,
725-
const char *key, unsigned int key_length,
726-
int using_trx);
727-
728-
729716
/**
730717
Provide a handler data getter to simplify coding
731718
*/

include/mysql/plugin_audit.h.pp

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
unsigned long long *pos_var);
107107
unsigned long thd_get_thread_id(const void* thd);
108108
void thd_get_xid(const void* thd, MYSQL_XID *xid);
109-
void mysql_query_cache_invalidate4(void* thd,
110-
const char *key, unsigned int key_length,
111-
int using_trx);
112109
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
113110
void thd_set_ha_data(void* thd, const struct handlerton *hton,
114111
const void *ha_data);

include/mysql/plugin_auth.h.pp

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
unsigned long long *pos_var);
107107
unsigned long thd_get_thread_id(const void* thd);
108108
void thd_get_xid(const void* thd, MYSQL_XID *xid);
109-
void mysql_query_cache_invalidate4(void* thd,
110-
const char *key, unsigned int key_length,
111-
int using_trx);
112109
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
113110
void thd_set_ha_data(void* thd, const struct handlerton *hton,
114111
const void *ha_data);

include/mysql/plugin_ftparser.h.pp

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
unsigned long long *pos_var);
107107
unsigned long thd_get_thread_id(const void* thd);
108108
void thd_get_xid(const void* thd, MYSQL_XID *xid);
109-
void mysql_query_cache_invalidate4(void* thd,
110-
const char *key, unsigned int key_length,
111-
int using_trx);
112109
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
113110
void thd_set_ha_data(void* thd, const struct handlerton *hton,
114111
const void *ha_data);

include/mysql/plugin_keyring.h.pp

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
unsigned long long *pos_var);
107107
unsigned long thd_get_thread_id(const void* thd);
108108
void thd_get_xid(const void* thd, MYSQL_XID *xid);
109-
void mysql_query_cache_invalidate4(void* thd,
110-
const char *key, unsigned int key_length,
111-
int using_trx);
112109
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
113110
void thd_set_ha_data(void* thd, const struct handlerton *hton,
114111
const void *ha_data);

include/mysql_com.h

-10
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@
182182
*/
183183
#define REFRESH_FAST 32768
184184

185-
/** RESET (remove all queries) from query cache */
186-
#define REFRESH_QUERY_CACHE 65536
187-
#define REFRESH_QUERY_CACHE_FREE 0x20000L /**< pack query cache */
188185
#define REFRESH_USER_RESOURCES 0x80000L
189186
#define REFRESH_FOR_EXPORT 0x100000L /** FLUSH TABLES ... FOR EXPORT */
190187
#define REFRESH_OPTIMIZER_COSTS 0x200000L /** FLUSH OPTIMIZER_COSTS */
@@ -805,13 +802,6 @@ typedef struct st_net {
805802
unsigned char reading_or_writing;
806803
char save_char;
807804
bool compress;
808-
/**
809-
Pointer to query object in query cache, do not equal NULL (0) for
810-
queries in cache that have not stored its results yet
811-
812-
Unused, please remove with the next incompatible ABI change.
813-
*/
814-
unsigned char *unused;
815805
unsigned int last_errno;
816806
unsigned char error;
817807
/** Client library error message buffer. Actually belongs to struct MYSQL. */

mysql-test/include/have_query_cache_disabled.inc

-36
This file was deleted.

mysql-test/include/mix1.inc

-32
Original file line numberDiff line numberDiff line change
@@ -467,38 +467,6 @@ DROP TABLE t1;
467467

468468
--source include/innodb_rollback_on_timeout.inc
469469

470-
#
471-
# Bug #27210: INNODB ON DUPLICATE KEY UPDATE
472-
#
473-
474-
set @save_qcache_size=@@global.query_cache_size;
475-
set @save_qcache_type=@@global.query_cache_type;
476-
set global query_cache_size=10*1024*1024;
477-
set global query_cache_type=1;
478-
connect (con1,localhost,root,,);
479-
connection con1;
480-
drop table if exists `test`;
481-
CREATE TABLE `test` (`test1` varchar(3) NOT NULL,
482-
`test2` varchar(4) NOT NULL,PRIMARY KEY (`test1`))
483-
ENGINE=InnoDB DEFAULT CHARSET=latin1;
484-
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '5678');
485-
disconnect con1;
486-
connect (con2,localhost,root,,);
487-
connection con2;
488-
select * from test;
489-
INSERT INTO `test` (`test1`, `test2`) VALUES ('tes', '1234')
490-
ON DUPLICATE KEY UPDATE `test2` = '1234';
491-
select * from test;
492-
flush tables;
493-
select * from test;
494-
disconnect con2;
495-
connection default;
496-
drop table test;
497-
set global query_cache_type=@save_qcache_type;
498-
set global query_cache_size=@save_qcache_size;
499-
500-
--source include/innodb_rollback_on_timeout.inc
501-
502470
#
503471
# Bug #27650: INSERT fails after multi-row INSERT of the form:
504472
# INSERT INTO t (id...) VALUES (NULL...) ON DUPLICATE KEY UPDATE id=VALUES(id)

mysql-test/r/func_misc.result

+2-72
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,10 @@ t1 CREATE TABLE `t1` (
100100
) ENGINE=ENGINE DEFAULT CHARSET=utf8mb4
101101
drop table t1;
102102
#------------------------------------------------------------------------
103-
# Tests for Bug#6760 and Bug#12689
103+
# Test for Bug#6760
104104
SET @row_count = 4;
105105
SET @sleep_time_per_result_row = 1;
106106
SET @max_acceptable_delay = 2;
107-
SET @save_query_cache_size=@@query_cache_size;
108-
SET @@global.query_cache_size = 1024 * 64;
109107
DROP TEMPORARY TABLE IF EXISTS t_history;
110108
DROP TABLE IF EXISTS t1;
111109
CREATE TEMPORARY TABLE t_history (attempt SMALLINT,
@@ -116,83 +114,15 @@ INSERT INTO t1 VALUES (1);
116114
INSERT INTO t1 VALUES (1);
117115
INSERT INTO t1 VALUES (1);
118116
INSERT INTO t1 VALUES (1);
119-
INSERT INTO t_history
120-
SET attempt = 4 - 4 + 1, start_ts = NOW(),
121-
start_cached = 0;
122-
SELECT *, SLEEP(@sleep_time_per_result_row) FROM t1;
123-
f1 SLEEP(@sleep_time_per_result_row)
124-
1 0
125-
1 0
126-
1 0
127-
1 0
128-
UPDATE t_history SET end_ts = NOW()
129-
WHERE attempt = 4 - 4 + 1;
130-
UPDATE t_history SET end_cached = 0
131-
WHERE attempt = 4 - 4 + 1;
132-
INSERT INTO t_history
133-
SET attempt = 4 - 3 + 1, start_ts = NOW(),
134-
start_cached = 0;
135-
SELECT *, SLEEP(@sleep_time_per_result_row) FROM t1;
136-
f1 SLEEP(@sleep_time_per_result_row)
137-
1 0
138-
1 0
139-
1 0
140-
1 0
141-
UPDATE t_history SET end_ts = NOW()
142-
WHERE attempt = 4 - 3 + 1;
143-
UPDATE t_history SET end_cached = 0
144-
WHERE attempt = 4 - 3 + 1;
145-
INSERT INTO t_history
146-
SET attempt = 4 - 2 + 1, start_ts = NOW(),
147-
start_cached = 0;
148-
SELECT *, SLEEP(@sleep_time_per_result_row) FROM t1;
149-
f1 SLEEP(@sleep_time_per_result_row)
150-
1 0
151-
1 0
152-
1 0
153-
1 0
154-
UPDATE t_history SET end_ts = NOW()
155-
WHERE attempt = 4 - 2 + 1;
156-
UPDATE t_history SET end_cached = 0
157-
WHERE attempt = 4 - 2 + 1;
158-
INSERT INTO t_history
159-
SET attempt = 4 - 1 + 1, start_ts = NOW(),
160-
start_cached = 0;
161-
SELECT *, SLEEP(@sleep_time_per_result_row) FROM t1;
162-
f1 SLEEP(@sleep_time_per_result_row)
163-
1 0
164-
1 0
165-
1 0
166-
1 0
167-
UPDATE t_history SET end_ts = NOW()
168-
WHERE attempt = 4 - 1 + 1;
169-
UPDATE t_history SET end_cached = 0
170-
WHERE attempt = 4 - 1 + 1;
171117
# Test 1: Does the query with SLEEP need a reasonable time?
172-
SELECT COUNT(*) >= 4 - 1 INTO @aux1 FROM t_history
118+
SELECT COUNT(*) >= - 1 INTO @aux1 FROM t_history
173119
WHERE TIMEDIFF(end_ts,start_ts) - @sleep_time_per_result_row * @row_count
174120
BETWEEN 0 AND @max_acceptable_delay;
175121
SELECT @aux1 AS "Expect 1";
176122
Expect 1
177123
1
178-
# Test 2: Does the query with SLEEP need a reasonable time even in case
179-
# of the non first execution?
180-
SELECT COUNT(*) >= 4 - 1 - 1 INTO @aux2 FROM t_history
181-
WHERE TIMEDIFF(end_ts,start_ts) - @sleep_time_per_result_row * @row_count
182-
BETWEEN 0 AND @max_acceptable_delay
183-
AND attempt > 1;
184-
SELECT @aux2 AS "Expect 1";
185-
Expect 1
186-
1
187-
# Test 3: The query with SLEEP must be not cached.
188-
SELECT COUNT(*) = 4 INTO @aux3 FROM t_history
189-
WHERE end_cached = start_cached;
190-
SELECT @aux3 AS "Expect 1";
191-
Expect 1
192-
1
193124
DROP TABLE t1;
194125
DROP TEMPORARY TABLE t_history;
195-
SET @@global.query_cache_size = @save_query_cache_size;
196126
create table t1 select INET_ATON('255.255.0.1') as `a`;
197127
show create table t1;
198128
Table Create Table

mysql-test/r/mysqld--help-notwin.result

-17
Original file line numberDiff line numberDiff line change
@@ -900,18 +900,6 @@ The following options may be given as the first argument:
900900
Limit of query profiling memory
901901
--query-alloc-block-size=#
902902
Allocation block size for query parsing and execution
903-
--query-cache-limit=#
904-
Don't cache results that are bigger than this
905-
--query-cache-min-res-unit=#
906-
The minimum size for blocks allocated by the query cache
907-
--query-cache-size=#
908-
The memory allocated to store results from old queries
909-
--query-cache-type=name
910-
OFF = Don't cache or retrieve results. ON = Cache all
911-
results except SELECT SQL_NO_CACHE ... queries. DEMAND =
912-
Cache only SELECT SQL_CACHE ... queries
913-
--query-cache-wlock-invalidate
914-
Invalidate queries in query cache on LOCK for write
915903
--query-prealloc-size=#
916904
Persistent buffer for query parsing and execution
917905
--range-alloc-block-size=#
@@ -1545,11 +1533,6 @@ port-open-timeout 0
15451533
preload-buffer-size 32768
15461534
profiling-history-size 15
15471535
query-alloc-block-size 8192
1548-
query-cache-limit 1048576
1549-
query-cache-min-res-unit 4096
1550-
query-cache-size 0
1551-
query-cache-type OFF
1552-
query-cache-wlock-invalidate FALSE
15531536
query-prealloc-size 8192
15541537
range-alloc-block-size 4096
15551538
range-optimizer-max-mem-size 8388608

mysql-test/r/mysqld--help-win.result

-17
Original file line numberDiff line numberDiff line change
@@ -890,18 +890,6 @@ The following options may be given as the first argument:
890890
Limit of query profiling memory
891891
--query-alloc-block-size=#
892892
Allocation block size for query parsing and execution
893-
--query-cache-limit=#
894-
Don't cache results that are bigger than this
895-
--query-cache-min-res-unit=#
896-
The minimum size for blocks allocated by the query cache
897-
--query-cache-size=#
898-
The memory allocated to store results from old queries
899-
--query-cache-type=name
900-
OFF = Don't cache or retrieve results. ON = Cache all
901-
results except SELECT SQL_NO_CACHE ... queries. DEMAND =
902-
Cache only SELECT SQL_CACHE ... queries
903-
--query-cache-wlock-invalidate
904-
Invalidate queries in query cache on LOCK for write
905893
--query-prealloc-size=#
906894
Persistent buffer for query parsing and execution
907895
--range-alloc-block-size=#
@@ -1540,11 +1528,6 @@ port-open-timeout 0
15401528
preload-buffer-size 32768
15411529
profiling-history-size 15
15421530
query-alloc-block-size 8192
1543-
query-cache-limit 1048576
1544-
query-cache-min-res-unit 4096
1545-
query-cache-size 0
1546-
query-cache-type OFF
1547-
query-cache-wlock-invalidate FALSE
15481531
query-prealloc-size 8192
15491532
range-alloc-block-size 4096
15501533
range-optimizer-max-mem-size 8388608

mysql-test/r/udf.result

-24
Original file line numberDiff line numberDiff line change
@@ -342,30 +342,6 @@ drop function f3;
342342
drop function metaphon;
343343
drop function myfunc_double;
344344
drop function myfunc_int;
345-
CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
346-
create table t1 (a char);
347-
SET @save_query_cache_size = @@query_cache_size;
348-
set GLOBAL query_cache_size=1355776;
349-
reset query cache;
350-
select metaphon('MySQL') from t1;
351-
metaphon('MySQL')
352-
show status like "Qcache_hits";
353-
Variable_name Value
354-
Qcache_hits 0
355-
show status like "Qcache_queries_in_cache";
356-
Variable_name Value
357-
Qcache_queries_in_cache 0
358-
select metaphon('MySQL') from t1;
359-
metaphon('MySQL')
360-
show status like "Qcache_hits";
361-
Variable_name Value
362-
Qcache_hits 0
363-
show status like "Qcache_queries_in_cache";
364-
Variable_name Value
365-
Qcache_queries_in_cache 0
366-
drop table t1;
367-
drop function metaphon;
368-
set GLOBAL query_cache_size=@save_query_cache_size;
369345
DROP DATABASE IF EXISTS mysqltest;
370346
CREATE DATABASE mysqltest;
371347
USE mysqltest;

0 commit comments

Comments
 (0)