summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-11-22 00:33:15 +0200
committerunknown <bell@sanja.is.com.ua>2002-11-22 00:33:15 +0200
commit51828aa9459f33cdce350abee8ca77c9a82bf5b6 (patch)
treeb435c42cf5ff11d8d099465a4944b83164c4bdee
parent63a2ba1b02172de5339b867f836928661c40a08f (diff)
downloadmariadb-git-51828aa9459f33cdce350abee8ca77c9a82bf5b6.tar.gz
fixed invalidation of query cache
excluded double call of 'invalidate()' mysql-test/r/innodb_cache.result: test of invalidation mysql-test/t/innodb_cache.test: test of invalidation sql/handler.cc: excluded double call of 'invalidate()' sql/sql_delete.cc: fixed invalidation of query cache sql/sql_insert.cc: fixed invalidation of query cache sql/sql_update.cc: fixed invalidation of query cache
-rw-r--r--mysql-test/r/innodb_cache.result10
-rw-r--r--mysql-test/t/innodb_cache.test9
-rw-r--r--sql/handler.cc2
-rw-r--r--sql/sql_delete.cc10
-rw-r--r--sql/sql_insert.cc9
-rw-r--r--sql/sql_update.cc10
6 files changed, 30 insertions, 20 deletions
diff --git a/mysql-test/r/innodb_cache.result b/mysql-test/r/innodb_cache.result
index eaa030046da..47abcb45fe5 100644
--- a/mysql-test/r/innodb_cache.result
+++ b/mysql-test/r/innodb_cache.result
@@ -98,3 +98,13 @@ commit;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
+drop table if exists t1;
+CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=InnoDB;
+select count(*) from t1;
+count(*)
+0
+insert into t1 (id) values (0);
+select count(*) from t1;
+count(*)
+1
+drop table t1;
diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test
index 21d30420eaf..9066a5f19ba 100644
--- a/mysql-test/t/innodb_cache.test
+++ b/mysql-test/t/innodb_cache.test
@@ -47,4 +47,11 @@ select * from t3;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
commit;
-show status like "Qcache_queries_in_cache"; \ No newline at end of file
+show status like "Qcache_queries_in_cache";
+
+drop table if exists t1;
+CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=InnoDB;
+select count(*) from t1;
+insert into t1 (id) values (0);
+select count(*) from t1;
+drop table t1;
diff --git a/sql/handler.cc b/sql/handler.cc
index f07e90d2eb9..c4e742ef519 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -314,7 +314,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
}
#endif
#ifdef HAVE_QUERY_CACHE
- if (transaction_commited)
+ if (transaction_commited && thd->transaction.changed_tables)
query_cache.invalidate(thd->transaction.changed_tables);
#endif /*HAVE_QUERY_CACHE*/
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 5f2d7e36a04..1361ff39388 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -179,14 +179,12 @@ cleanup:
if (ha_autocommit_or_rollback(thd,error >= 0))
error=1;
}
+
/*
- Only invalidate the query cache if something changed or if we
- didn't commit the transacion (query cache is automaticly
- invalidated on commit)
+ Store table for future invalidation or invalidate it in
+ the query cache if something changed
*/
- if (deleted &&
- (!transactional_table ||
- thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+ if (deleted)
{
query_cache_invalidate3(thd, table_list, 1);
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 2508314c469..6ce2b50fc36 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -319,13 +319,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, List<Item> &fields,
error=ha_autocommit_or_rollback(thd,error);
/*
- Only invalidate the query cache if something changed or if we
- didn't commit the transacion (query cache is automaticly
- invalidated on commit)
+ Store table for future invalidation or invalidate it in
+ the query cache if something changed
*/
- if ((info.copied || info.deleted) &&
- (!transactional_table ||
- thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+ if (info.copied || info.deleted)
{
query_cache_invalidate3(thd, table_list, 1);
}
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index b5263322301..97e6ea43bfd 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -318,14 +318,12 @@ int mysql_update(THD *thd,
if (ha_autocommit_or_rollback(thd, error >= 0))
error=1;
}
+
/*
- Only invalidate the query cache if something changed or if we
- didn't commit the transacion (query cache is automaticly
- invalidated on commit)
+ Store table for future invalidation or invalidate it in
+ the query cache if something changed
*/
- if (updated &&
- (!transactional_table ||
- thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
+ if (updated)
{
query_cache_invalidate3(thd, table_list, 1);
}