Commit fc4364e3 authored by unknown's avatar unknown
Browse files

InnoDB: Add option for disabling innodb_status.<pid> files.

InnoDB: Implement tmpfile() differently on Windows (Bug #3998)


innobase/dict/dict0dict.c:
  Check the return value of os_file_create_tmpfile(),
  as it can now return NULL
innobase/include/os0file.h:
  Note that os_file_create_tmpfile() can now return NULL
innobase/include/srv0srv.h:
  Add a new server flag (srv_innodb_status) to disable
  the creation of innodb_status.<pid> files
innobase/lock/lock0lock.c:
  Check the return value of os_file_create_tmpfile(),
  as it can now return NULL
innobase/os/os0file.c:
  os_file_create_tmpfile(): separate implementation for Win32;
  errors will be reported but will not cause assertion failure
innobase/srv/srv0srv.c:
  Add a new server flag (srv_innodb_status) to disable
  the creation of innodb_status.<pid> files
innobase/srv/srv0start.c:
  innobase_start_or_create_for_mysql(): create srv_monitor_file
  with tmpfile() or with a visible name "innodb_status.<pid>",
  depending on the setting of the flag srv_innodb_status.
sql/ha_innodb.cc:
  innobase_init(): initialize srv_innodb_status
  update_table_comment(), get_foreign_key_create_info(): replace
  tmpfile() with os_file_create_tmpfile()
sql/ha_innodb.h:
  Add new Boolean flag, innobase_create_status_file.
sql/mysqld.cc:
  Add new Boolean flag, innodb_status_file
parent 06cd2efc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -643,6 +643,7 @@ dict_init(void)
	rw_lock_set_level(&dict_operation_lock, SYNC_DICT_OPERATION);

	dict_foreign_err_file = os_file_create_tmpfile();
	ut_a(dict_foreign_err_file);
	mutex_create(&dict_foreign_err_mutex);
	mutex_set_level(&dict_foreign_err_mutex, SYNC_ANY_LATCH);
}
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ Creates a temporary file. In case of error, causes abnormal termination. */
FILE*
os_file_create_tmpfile(void);
/*========================*/
				/* out: temporary file handle (never NULL) */
				/* out: temporary file handle, or NULL */
/********************************************************************
A simple function to open or create a file. */

+2 −0
Original line number Diff line number Diff line
@@ -92,6 +92,8 @@ extern lint srv_conc_n_threads;

extern ibool	srv_fast_shutdown;

extern ibool	srv_innodb_status;

extern ibool	srv_use_doublewrite_buf;

extern ibool    srv_set_thread_priorities;
+1 −0
Original line number Diff line number Diff line
@@ -509,6 +509,7 @@ lock_sys_create(
	/* hash_create_mutexes(lock_sys->rec_hash, 2, SYNC_REC_LOCK); */

	lock_latest_err_file = os_file_create_tmpfile();
	ut_a(lock_latest_err_file);
}

/*************************************************************************
+21 −4
Original line number Diff line number Diff line
@@ -377,16 +377,33 @@ Creates a temporary file. In case of error, causes abnormal termination. */
FILE*
os_file_create_tmpfile(void)
/*========================*/
				/* out: temporary file handle (never NULL) */
				/* out: temporary file handle, or NULL */
{
	FILE*	file	= tmpfile();
	FILE*	file;
#ifdef __WIN__
	int	fd	= -1;
	char*	name;
	file = NULL;
	if (NULL == (name = tempnam(fil_path_to_mysql_datadir, "ib"))
		|| -1 == (fd = _open(name, _O_CREAT | _O_EXCL | _O_RDWR
			| _O_SEQUENTIAL | _O_SHORT_LIVED | _O_TEMPORARY))
		|| NULL == (file = fdopen(fd, "w+b"))) {
		ut_print_timestamp(stderr);
		fprintf(stderr, "  InnoDB: Error: unable to create"
			" temporary file %s\n", name ? name : "name");
		if (fd != -1) {
			_close(fd);
		}
	}
	free(name);
#else /* __WIN__ */
	file = tmpfile();
	if (file == NULL) {
		ut_print_timestamp(stderr);
		fputs("  InnoDB: Error: unable to create temporary file\n",
			stderr);
		os_file_handle_error(NULL, "tmpfile");
		ut_error;
	}
#endif /* __WIN__ */
	return(file);
}

Loading