summaryrefslogtreecommitdiff
path: root/sql/ha_innodb.cc
diff options
context:
space:
mode:
authorunknown <aivanov@mysql.com>2005-12-13 21:35:24 +0300
committerunknown <aivanov@mysql.com>2005-12-13 21:35:24 +0300
commit778d212b8ceb266c4c8cd2276fcf548c4c0851a3 (patch)
tree7a6cff8fdb54472ba07a9cea2610e458af775dd2 /sql/ha_innodb.cc
parent3bef007191f1e26a68f34c085f6d6611f5a9c388 (diff)
downloadmariadb-git-778d212b8ceb266c4c8cd2276fcf548c4c0851a3.tar.gz
Fix BUG#12071: "Windows hang:'Opening tables' or 'Waiting for
table' lockup". Changes from the innodb-5.0-ss92 snapshot. Do not call os_file_create_tmpfile() at runtime. Instead, create all tempfiles at startup and guard access to them with mutexes. innobase/btr/btr0sea.c: Changes from the innodb-5.0ss92 snapshot. innobase/include/buf0buf.h: Changes from the innodb-5.0ss92 snapshot. innobase/include/os0file.h: Changes from the innodb-5.0ss92 snapshot. innobase/include/srv0srv.h: Changes from the innodb-5.0ss92 snapshot. innobase/row/row0ins.c: Changes from the innodb-5.0ss92 snapshot. innobase/srv/srv0srv.c: Changes from the innodb-5.0ss92 snapshot. innobase/srv/srv0start.c: Changes from the innodb-5.0ss92 snapshot. mysql-test/r/innodb.result: Changes from the innodb-5.0ss92 snapshot. mysql-test/t/innodb.test: Changes from the innodb-5.0ss92 snapshot. sql/ha_innodb.cc: Changes from the innodb-5.0ss92 snapshot.
Diffstat (limited to 'sql/ha_innodb.cc')
-rw-r--r--sql/ha_innodb.cc109
1 files changed, 53 insertions, 56 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 6c8dc9f81f6..afeb1238aa7 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -5742,6 +5742,7 @@ ha_innobase::update_table_comment(
uint length = (uint) strlen(comment);
char* str;
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
+ long flen;
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
@@ -5761,43 +5762,43 @@ ha_innobase::update_table_comment(
trx_search_latch_release_if_reserved(prebuilt->trx);
str = NULL;
- if (FILE* file = os_file_create_tmpfile()) {
- long flen;
+ /* output the data to a temporary file */
- /* output the data to a temporary file */
- fprintf(file, "InnoDB free: %lu kB",
+ mutex_enter_noninline(&srv_dict_tmpfile_mutex);
+ rewind(srv_dict_tmpfile);
+
+ fprintf(srv_dict_tmpfile, "InnoDB free: %lu kB",
(ulong) fsp_get_available_space_in_free_extents(
prebuilt->table->space));
- dict_print_info_on_foreign_keys(FALSE, file,
+ dict_print_info_on_foreign_keys(FALSE, srv_dict_tmpfile,
prebuilt->trx, prebuilt->table);
- flen = ftell(file);
- if (flen < 0) {
- flen = 0;
- } else if (length + flen + 3 > 64000) {
- flen = 64000 - 3 - length;
- }
+ flen = ftell(srv_dict_tmpfile);
+ if (flen < 0) {
+ flen = 0;
+ } else if (length + flen + 3 > 64000) {
+ flen = 64000 - 3 - length;
+ }
- /* allocate buffer for the full string, and
- read the contents of the temporary file */
+ /* allocate buffer for the full string, and
+ read the contents of the temporary file */
- str = my_malloc(length + flen + 3, MYF(0));
+ str = my_malloc(length + flen + 3, MYF(0));
- if (str) {
- char* pos = str + length;
- if (length) {
- memcpy(str, comment, length);
- *pos++ = ';';
- *pos++ = ' ';
- }
- rewind(file);
- flen = (uint) fread(pos, 1, flen, file);
- pos[flen] = 0;
+ if (str) {
+ char* pos = str + length;
+ if (length) {
+ memcpy(str, comment, length);
+ *pos++ = ';';
+ *pos++ = ' ';
}
-
- fclose(file);
+ rewind(srv_dict_tmpfile);
+ flen = (uint) fread(pos, 1, flen, srv_dict_tmpfile);
+ pos[flen] = 0;
}
+ mutex_exit_noninline(&srv_dict_tmpfile_mutex);
+
prebuilt->trx->op_info = (char*)"";
return(str ? str : (char*) comment);
@@ -5815,6 +5816,7 @@ ha_innobase::get_foreign_key_create_info(void)
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
char* str = 0;
+ long flen;
ut_a(prebuilt != NULL);
@@ -5824,47 +5826,42 @@ ha_innobase::get_foreign_key_create_info(void)
update_thd(current_thd);
- if (FILE* file = os_file_create_tmpfile()) {
- long flen;
+ prebuilt->trx->op_info = (char*)"getting info on foreign keys";
- prebuilt->trx->op_info = (char*)"getting info on foreign keys";
+ /* In case MySQL calls this in the middle of a SELECT query,
+ release possible adaptive hash latch to avoid
+ deadlocks of threads */
- /* In case MySQL calls this in the middle of a SELECT query,
- release possible adaptive hash latch to avoid
- deadlocks of threads */
+ trx_search_latch_release_if_reserved(prebuilt->trx);
- trx_search_latch_release_if_reserved(prebuilt->trx);
+ mutex_enter_noninline(&srv_dict_tmpfile_mutex);
+ rewind(srv_dict_tmpfile);
- /* output the data to a temporary file */
- dict_print_info_on_foreign_keys(TRUE, file,
+ /* output the data to a temporary file */
+ dict_print_info_on_foreign_keys(TRUE, srv_dict_tmpfile,
prebuilt->trx, prebuilt->table);
- prebuilt->trx->op_info = (char*)"";
-
- flen = ftell(file);
- if (flen < 0) {
- flen = 0;
- } else if (flen > 64000 - 1) {
- flen = 64000 - 1;
- }
+ prebuilt->trx->op_info = (char*)"";
- /* allocate buffer for the string, and
- read the contents of the temporary file */
+ flen = ftell(srv_dict_tmpfile);
+ if (flen < 0) {
+ flen = 0;
+ } else if (flen > 64000 - 1) {
+ flen = 64000 - 1;
+ }
- str = my_malloc(flen + 1, MYF(0));
+ /* allocate buffer for the string, and
+ read the contents of the temporary file */
- if (str) {
- rewind(file);
- flen = (uint) fread(str, 1, flen, file);
- str[flen] = 0;
- }
+ str = my_malloc(flen + 1, MYF(0));
- fclose(file);
- } else {
- /* unable to create temporary file */
- str = my_strdup(
-"/* Error: cannot display foreign key constraints */", MYF(0));
+ if (str) {
+ rewind(srv_dict_tmpfile);
+ flen = (uint) fread(str, 1, flen, srv_dict_tmpfile);
+ str[flen] = 0;
}
+ mutex_exit_noninline(&srv_dict_tmpfile_mutex);
+
return(str);
}