Commit cf381ae4 authored by unknown's avatar unknown

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.


sql/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.
sql/sql_insert.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.
sql/sql_load.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.
sql/sql_update.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.
sql/ha_innodb.cc:
  Remove accidenatlly committed debug printfs when query cache is used
parent 720584b0
...@@ -560,12 +560,12 @@ innobase_query_caching_of_table_permitted( ...@@ -560,12 +560,12 @@ innobase_query_caching_of_table_permitted(
#endif #endif
if (row_search_check_if_query_cache_permitted(trx, norm_name)) { 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); 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); return((my_bool)FALSE);
} }
......
...@@ -178,6 +178,15 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, ...@@ -178,6 +178,15 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
(void) table->file->extra(HA_EXTRA_NORMAL); (void) table->file->extra(HA_EXTRA_NORMAL);
cleanup: 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(); transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table); log_delayed= (transactional_table || table->tmp_table);
if (deleted && (error <= 0 || !transactional_table)) if (deleted && (error <= 0 || !transactional_table))
...@@ -199,14 +208,6 @@ cleanup: ...@@ -199,14 +208,6 @@ cleanup:
error=1; 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) if (thd->lock)
{ {
mysql_unlock_tables(thd, thd->lock); mysql_unlock_tables(thd, thd->lock);
...@@ -480,6 +481,10 @@ bool multi_delete::send_eof() ...@@ -480,6 +481,10 @@ bool multi_delete::send_eof()
/* reset used flags */ /* reset used flags */
thd->proc_info="end"; 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 Write the SQL statement to the binlog if we deleted
...@@ -504,9 +509,6 @@ bool multi_delete::send_eof() ...@@ -504,9 +509,6 @@ bool multi_delete::send_eof()
if (transactional_tables) if (transactional_tables)
if (ha_autocommit_or_rollback(thd,local_error > 0)) if (ha_autocommit_or_rollback(thd,local_error > 0))
local_error=1; local_error=1;
if (deleted)
query_cache_invalidate3(thd, delete_tables, 1);
if (local_error) if (local_error)
::send_error(thd); ::send_error(thd);
......
...@@ -344,7 +344,18 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -344,7 +344,18 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
else if (table->next_number_field) else if (table->next_number_field)
id=table->next_number_field->val_int(); // Return auto_increment value 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(); transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table); log_delayed= (transactional_table || table->tmp_table);
if ((info.copied || info.deleted) && (error <= 0 || !transactional_table)) if ((info.copied || info.deleted) && (error <= 0 || !transactional_table))
{ {
...@@ -362,14 +373,6 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -362,14 +373,6 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
if (transactional_table) if (transactional_table)
error=ha_autocommit_or_rollback(thd,error); 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) if (thd->lock)
{ {
mysql_unlock_tables(thd, thd->lock); mysql_unlock_tables(thd, thd->lock);
...@@ -1420,11 +1423,11 @@ void select_insert::send_error(uint errcode,const char *err) ...@@ -1420,11 +1423,11 @@ void select_insert::send_error(uint errcode,const char *err)
::send_error(thd,errcode,err); ::send_error(thd,errcode,err);
table->file->extra(HA_EXTRA_NO_CACHE); table->file->extra(HA_EXTRA_NO_CACHE);
table->file->activate_all_index(thd); table->file->activate_all_index(thd);
ha_rollback_stmt(thd);
if (info.copied || info.deleted) if (info.copied || info.deleted)
{ {
query_cache_invalidate3(thd, table, 1); query_cache_invalidate3(thd, table, 1);
} }
ha_rollback_stmt(thd);
} }
...@@ -1435,6 +1438,14 @@ bool select_insert::send_eof() ...@@ -1435,6 +1438,14 @@ bool select_insert::send_eof()
error=table->file->activate_all_index(thd); error=table->file->activate_all_index(thd);
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); 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 */ /* Write to binlog before commiting transaction */
if (mysql_bin_log.is_open()) if (mysql_bin_log.is_open())
{ {
...@@ -1444,10 +1455,6 @@ bool select_insert::send_eof() ...@@ -1444,10 +1455,6 @@ bool select_insert::send_eof()
} }
if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error) if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error)
error=error2; error=error2;
if (info.copied || info.deleted)
{
query_cache_invalidate3(thd, table, 1);
}
if (error) if (error)
{ {
table->file->print_error(error,MYF(0)); table->file->print_error(error,MYF(0));
......
...@@ -283,6 +283,10 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -283,6 +283,10 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
table->copy_blobs=0; table->copy_blobs=0;
thd->count_cuted_fields=0; /* Don`t calc cuted fields */ 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 (error)
{ {
if (transactional_table) if (transactional_table)
...@@ -344,8 +348,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -344,8 +348,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
} }
if (transactional_table) if (transactional_table)
error=ha_autocommit_or_rollback(thd,error); error=ha_autocommit_or_rollback(thd,error);
query_cache_invalidate3(thd, table_list, 0);
err: err:
if (thd->lock) if (thd->lock)
{ {
......
...@@ -332,6 +332,21 @@ int mysql_update(THD *thd, ...@@ -332,6 +332,21 @@ int mysql_update(THD *thd,
free_io_cache(table); // If ORDER BY free_io_cache(table); // If ORDER BY
thd->proc_info="end"; thd->proc_info="end";
VOID(table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY)); 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(); transactional_table= table->file->has_transactions();
log_delayed= (transactional_table || table->tmp_table); log_delayed= (transactional_table || table->tmp_table);
if (updated && (error <= 0 || !transactional_table)) if (updated && (error <= 0 || !transactional_table))
...@@ -353,20 +368,6 @@ int mysql_update(THD *thd, ...@@ -353,20 +368,6 @@ int mysql_update(THD *thd,
error=1; 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; delete select;
free_underlaid_joins(thd, &thd->lex.select_lex); free_underlaid_joins(thd, &thd->lex.select_lex);
if (error >= 0) if (error >= 0)
...@@ -950,6 +951,14 @@ bool multi_update::send_eof() ...@@ -950,6 +951,14 @@ bool multi_update::send_eof()
int local_error = (table_count) ? do_updates(0) : 0; int local_error = (table_count) ? do_updates(0) : 0;
thd->proc_info= "end"; 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 Write the SQL statement to the binlog if we updated
rows and we succeeded or if we updated some non rows and we succeeded or if we updated some non
...@@ -988,10 +997,6 @@ bool multi_update::send_eof() ...@@ -988,10 +997,6 @@ bool multi_update::send_eof()
sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated, sprintf(buff,ER(ER_UPDATE_INFO), (long) found, (long) updated,
(long) thd->cuted_fields); (long) thd->cuted_fields);
if (updated)
{
query_cache_invalidate3(thd, update_tables, 1);
}
::send_ok(thd, ::send_ok(thd,
(thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated, (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated,
thd->insert_id_used ? thd->insert_id() : 0L,buff); thd->insert_id_used ? thd->insert_id() : 0L,buff);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment