summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheikki@hundin.mysql.fi <>2003-05-26 19:10:43 +0300
committerheikki@hundin.mysql.fi <>2003-05-26 19:10:43 +0300
commitb8e5b65f887589b5ef676578cbeee91cea3e68fe (patch)
tree1350dc4877b9878316638fceb4a88709e7cda9d7
parent31d0d44919eebfc5f83fe82ae38312f13541144a (diff)
downloadmariadb-git-b8e5b65f887589b5ef676578cbeee91cea3e68fe.tar.gz
ha_innodb.cc:
Remove accidenatlly committed debug printfs when query cache is used sql_update.cc, sql_load.cc, sql_insert.cc, sql_delete.cc: For the transactional query cache algorithm to work we must invalidate the query cache in INSERT/DELETE/UPDATE before writing to the binlog or calling ha_autocommit_... Note that binlog writing may also call commit. The crucial thing is that the transaction which modified data must not be committed BEFORE the query cache is invalidated.
-rw-r--r--sql/ha_innodb.cc4
-rw-r--r--sql/sql_delete.cc24
-rw-r--r--sql/sql_insert.cc33
-rw-r--r--sql/sql_load.cc6
-rw-r--r--sql/sql_update.cc41
5 files changed, 62 insertions, 46 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index a426dc5a9a9..bf4dc7e5066 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -560,12 +560,12 @@ innobase_query_caching_of_table_permitted(
#endif
if (row_search_check_if_query_cache_permitted(trx, norm_name)) {
- printf("Query cache for %s permitted\n", norm_name);
+ /* printf("Query cache for %s permitted\n", norm_name); */
return((my_bool)TRUE);
}
- printf("Query cache for %s NOT permitted\n", norm_name);
+ /* printf("Query cache for %s NOT permitted\n", norm_name); */
return((my_bool)FALSE);
}
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index a12f6efb006..9c1743eeb12 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -178,6 +178,15 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
(void) table->file->extra(HA_EXTRA_NORMAL);
cleanup:
+ /*
+ Invalidate the table in the query cache if something changed. This must
+ be before binlog writing and ha_autocommit_...
+ */
+ if (deleted)
+ {
+ query_cache_invalidate3(thd, table_list, 1);
+ }
+
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if (deleted && (error <= 0 || !transactional_table))
@@ -199,14 +208,6 @@ cleanup:
error=1;
}
- /*
- Store table for future invalidation or invalidate it in
- the query cache if something changed
- */
- if (deleted)
- {
- query_cache_invalidate3(thd, table_list, 1);
- }
if (thd->lock)
{
mysql_unlock_tables(thd, thd->lock);
@@ -480,6 +481,10 @@ bool multi_delete::send_eof()
/* reset used flags */
thd->proc_info="end";
+ /* We must invalidate the query cache before binlog writing and
+ ha_autocommit_... */
+ if (deleted)
+ query_cache_invalidate3(thd, delete_tables, 1);
/*
Write the SQL statement to the binlog if we deleted
@@ -504,9 +509,6 @@ bool multi_delete::send_eof()
if (transactional_tables)
if (ha_autocommit_or_rollback(thd,local_error > 0))
local_error=1;
-
- if (deleted)
- query_cache_invalidate3(thd, delete_tables, 1);
if (local_error)
::send_error(thd);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 9be0270947a..48cc6d4e254 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -344,7 +344,18 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else if (table->next_number_field)
id=table->next_number_field->val_int(); // Return auto_increment value
+ /*
+ Invalidate the table in the query cache if something changed.
+ For the transactional algorithm to work the invalidation must be
+ before binlog writing and ha_autocommit_...
+ */
+ if (info.copied || info.deleted)
+ {
+ query_cache_invalidate3(thd, table_list, 1);
+ }
+
transactional_table= table->file->has_transactions();
+
log_delayed= (transactional_table || table->tmp_table);
if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
{
@@ -362,14 +373,6 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
if (transactional_table)
error=ha_autocommit_or_rollback(thd,error);
- /*
- Store table for future invalidation or invalidate it in
- the query cache if something changed
- */
- if (info.copied || info.deleted)
- {
- query_cache_invalidate3(thd, table_list, 1);
- }
if (thd->lock)
{
mysql_unlock_tables(thd, thd->lock);
@@ -1420,11 +1423,11 @@ void select_insert::send_error(uint errcode,const char *err)
::send_error(thd,errcode,err);
table->file->extra(HA_EXTRA_NO_CACHE);
table->file->activate_all_index(thd);
- ha_rollback_stmt(thd);
if (info.copied || info.deleted)
{
query_cache_invalidate3(thd, table, 1);
}
+ ha_rollback_stmt(thd);
}
@@ -1435,6 +1438,14 @@ bool select_insert::send_eof()
error=table->file->activate_all_index(thd);
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
+ /* We must invalidate the table in the query cache before binlog writing
+ and ha_autocommit_... */
+
+ if (info.copied || info.deleted)
+ {
+ query_cache_invalidate3(thd, table, 1);
+ }
+
/* Write to binlog before commiting transaction */
if (mysql_bin_log.is_open())
{
@@ -1444,10 +1455,6 @@ bool select_insert::send_eof()
}
if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error)
error=error2;
- if (info.copied || info.deleted)
- {
- query_cache_invalidate3(thd, table, 1);
- }
if (error)
{
table->file->print_error(error,MYF(0));
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index 7476472a79a..b79a3b739d7 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -283,6 +283,10 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table->copy_blobs=0;
thd->count_cuted_fields=0; /* Don`t calc cuted fields */
+ /* We must invalidate the table in query cache before binlog writing and
+ ha_autocommit_... */
+ query_cache_invalidate3(thd, table_list, 0);
+
if (error)
{
if (transactional_table)
@@ -344,8 +348,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
}
if (transactional_table)
error=ha_autocommit_or_rollback(thd,error);
- query_cache_invalidate3(thd, table_list, 0);
-
err:
if (thd->lock)
{
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 9d4d7ccbbab..62fcb02163d 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -332,6 +332,21 @@ int mysql_update(THD *thd,
free_io_cache(table); // If ORDER BY
thd->proc_info="end";
VOID(table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY));
+
+ /*
+ Invalidate the table in the query cache if something changed.
+ This must be before binlog writing and ha_autocommit_...
+ */
+ if (updated)
+ {
+ query_cache_invalidate3(thd, table_list, 1);
+ }
+ if (thd->lock)
+ {
+ mysql_unlock_tables(thd, thd->lock);
+ thd->lock=0;
+ }
+
transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table);
if (updated && (error <= 0 || !transactional_table))
@@ -353,20 +368,6 @@ int mysql_update(THD *thd,
error=1;
}
- /*
- Store table for future invalidation or invalidate it in
- the query cache if something changed
- */
- if (updated)
- {
- query_cache_invalidate3(thd, table_list, 1);
- }
- if (thd->lock)
- {
- mysql_unlock_tables(thd, thd->lock);
- thd->lock=0;
- }
-
delete select;
free_underlaid_joins(thd, &thd->lex.select_lex);
if (error >= 0)
@@ -950,6 +951,14 @@ bool multi_update::send_eof()
int local_error = (table_count) ? do_updates(0) : 0;
thd->proc_info= "end";
+ /* We must invalidate the query cache before binlog writing and
+ ha_autocommit_... */
+
+ if (updated)
+ {
+ query_cache_invalidate3(thd, update_tables, 1);
+ }
+
/*
Write the SQL statement to the binlog if we updated
rows and we succeeded or if we updated some non
@@ -988,10 +997,6 @@ bool multi_update::send_eof()
sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated,
(long) thd->cuted_fields);
- if (updated)
- {
- query_cache_invalidate3(thd, update_tables, 1);
- }
::send_ok(thd,
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
thd->insert_id_used ? thd->insert_id() : 0L,buff);