diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-09-20 05:11:08 +0300 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-09-20 05:11:08 +0300 |
commit | b8cfcf768ef493218b3917caf179c90c00632452 (patch) | |
tree | 83fa0b9921ca4d827b9a72cf561764aaaa2e4296 /innobase/row | |
parent | ebf518bc45b19cc0118422773c99d16b84420518 (diff) | |
download | mariadb-git-b8cfcf768ef493218b3917caf179c90c00632452.tar.gz |
Many files:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
os0file.c:
Use unbuffered i/o in Windows
innobase/dict/dict0mem.c:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
innobase/os/os0file.c:
Use unbuffered i/o in Windows
innobase/lock/lock0lock.c:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
innobase/row/row0ins.c:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
innobase/row/row0mysql.c:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
innobase/row/row0sel.c:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
innobase/srv/srv0srv.c:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
sql/ha_innodb.h:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
sql/ha_innodb.cc:
Modifications for query cache + trxs, fix of q.c.+ foreign keys
Diffstat (limited to 'innobase/row')
-rw-r--r-- | innobase/row/row0ins.c | 37 | ||||
-rw-r--r-- | innobase/row/row0mysql.c | 15 | ||||
-rw-r--r-- | innobase/row/row0sel.c | 54 |
3 files changed, 93 insertions, 13 deletions
diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index 2e6dde6db65..7c20afbe467 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -32,6 +32,23 @@ Created 4/20/1996 Heikki Tuuri #define ROW_INS_PREV 1 #define ROW_INS_NEXT 2 + +/********************************************************************* +This prototype is copied from /mysql/sql/ha_innodb.cc. +Invalidates the MySQL query cache for the table. +NOTE that the exact prototype of this function has to be in +/innobase/row/row0ins.c! */ + +void +innobase_invalidate_query_cache( +/*============================*/ + trx_t* trx, /* in: transaction which modifies the table */ + char* full_name, /* in: concatenation of database name, null + char '\0', table name; NOTE that in + Windows this is always in LOWER CASE! */ + ulint full_name_len); /* in: full name length */ + + /************************************************************************* Creates an insert node struct. */ @@ -386,10 +403,30 @@ row_ins_foreign_delete_or_set_null( upd_t* update; ulint err; ulint i; + char* ptr; + char table_name_buf[1000]; char err_buf[1000]; ut_a(thr && foreign && pcur && mtr); + /* Since we are going to delete or update a row, we have to invalidate + the MySQL query cache for table */ + + ut_a(ut_strlen(table->name) < 998); + + ut_memcpy(table_name_buf, table->name, ut_strlen(table->name) + 1); + + ptr = table_name_buf; + + while (*ptr != '/') { + ptr++; + } + + *ptr = '\0'; + + /* We call a function in ha_innodb.cc */ + innobase_invalidate_query_cache(thr_get_trx(thr), table_name_buf, + ut_strlen(table->name)); node = thr->run_node; ut_a(que_node_get_type(node) == QUE_NODE_UPDATE); diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index dc028b1c67b..43eef8c5092 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1186,12 +1186,7 @@ row_create_table_for_mysql( ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(mutex_own(&(dict_sys->mutex))); - /* We allow a create table also if innodb_force_recovery is used. This - enables the user to stop a runaway rollback or a crash caused by - a temporary table #sql... He can use the trick explained in the - manual to rename the temporary table to rsql..., and then drop it. */ - - if (srv_created_new_raw) { + if (srv_created_new_raw || srv_force_recovery) { fprintf(stderr, "InnoDB: A new raw disk partition was initialized or\n" "InnoDB: innodb_force_recovery is on: we do not allow\n" @@ -1712,13 +1707,7 @@ row_drop_table_for_mysql( ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_a(name != NULL); - /* Note that we allow dropping of a table even if innodb_force_recovery - is used. If a rollback or purge would crash because of a corrupt - table, the user can try dropping it to avoid the crash. This is also - a nice way to stop a runaway rollback caused by a failing big - table import in a single transaction. */ - - if (srv_created_new_raw) { + if (srv_created_new_raw || srv_force_recovery) { fprintf(stderr, "InnoDB: A new raw disk partition was initialized or\n" "InnoDB: innodb_force_recovery is on: we do not allow\n" diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index f3dced15fdf..4af04251996 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -30,6 +30,7 @@ Created 12/19/1997 Heikki Tuuri #include "pars0sym.h" #include "pars0pars.h" #include "row0mysql.h" +#include "read0read.h" /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 @@ -3115,3 +3116,56 @@ normal_return: return(ret); } + +/*********************************************************************** +Checks if MySQL at the moment is allowed for this table to retrieve a +consistent read result, or store it to the query cache. */ + +ibool +row_search_check_if_query_cache_permitted( +/*======================================*/ + /* out: TRUE if storing or retrieving from + the query cache is permitted */ + trx_t* trx, /* in: transaction object */ + char* norm_name) /* in: concatenation of database name, '/' + char, table name */ +{ + dict_table_t* table; + ibool ret = FALSE; + + table = dict_table_get(norm_name, trx); + + if (table == NULL) { + + return(FALSE); + } + + mutex_enter(&kernel_mutex); + + /* Start the transaction if it is not started yet */ + + trx_start_if_not_started_low(trx); + + /* If there are locks on the table or some trx has invalidated the + cache up to our trx id, then ret = FALSE. + We do not check what type locks there are on the table, though only + IX type locks actually would require ret = FALSE. */ + + if (UT_LIST_GET_LEN(table->locks) == 0 + && ut_dulint_cmp(trx->id, table->query_cache_inv_trx_id) >= 0) { + + ret = TRUE; + + /* Assign a read view for the transaction if it does not yet + have one */ + + if (!trx->read_view) { + trx->read_view = read_view_open_now(trx, + trx->read_view_heap); + } + } + + mutex_exit(&kernel_mutex); + + return(ret); +} |