From 238b226f2626573021103872b85d54a79c5743ea Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jul 2004 14:15:38 +0300 Subject: Added innodb_locks_unsafe_for_binlog option. This option turns off Innodb next-key locking. Using this option the locks InnoDB sets on index records do not affect the ``gap'' before that index record. Thus, this option allows phantom problem. innobase/include/srv0srv.h: Added srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option. innobase/row/row0sel.c: If innodb_locks_unsafe_for_binlog option is used, we lock only the record, i.e. next-key locking is not used. Therefore, setting lock to the index record do not affect the ``gap'' before that index record. Thus, this option allows phantom problem, because concurrent insert operations are allowed inside the select range. innobase/srv/srv0srv.c: Added srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option. sql/ha_innodb.cc: Added innobase_locks_unsafe_for_binlog and srv_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option. sql/ha_innodb.h: Added innobase_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option. sql/mysqld.cc: Added OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG, innobase_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option. sql/set_var.cc: Added innodb_locks_unsafe_for_binlog and innobase_locks_unsafe_for_binlog for innodb_locks_unsafe_for_binlog option. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/ha_innodb.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 6eae315e443..a7dce3a6ab8 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -117,6 +117,7 @@ my_bool innobase_log_archive = FALSE;/* unused */ my_bool innobase_use_native_aio = FALSE; my_bool innobase_fast_shutdown = TRUE; my_bool innobase_file_per_table = FALSE; +my_bool innobase_locks_unsafe_for_binlog = FALSE; static char *internal_innobase_data_file_path = NULL; @@ -908,6 +909,7 @@ innobase_init(void) srv_fast_shutdown = (ibool) innobase_fast_shutdown; srv_file_per_table = (ibool) innobase_file_per_table; + srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog; srv_max_n_open_files = (ulint) innobase_open_files; -- cgit v1.2.1 From 979126224b4a04a548e7663c72e4212de6121f20 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jul 2004 16:08:19 +0300 Subject: ha_innodb.cc: ha_innobase::create(): pass the query string as UTF-8 to row_table_add_foreign_constraints() (Bug #4649) sql/ha_innodb.cc: ha_innobase::create(): pass the query string as UTF-8 to row_table_add_foreign_constraints() (Bug #4649) --- sql/ha_innodb.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index c06448647d5..a8309d4f32c 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3642,11 +3642,19 @@ ha_innobase::create( } if (current_thd->query != NULL) { - - error = row_table_add_foreign_constraints(trx, - current_thd->query, norm_name); - error = convert_error_code_to_mysql(error, NULL); + LEX_STRING q; + if (thd->convert_string(&q, system_charset_info, + current_thd->query, + current_thd->query_length, + current_thd->charset())) { + error = HA_ERR_OUT_OF_MEM; + } else { + error = row_table_add_foreign_constraints(trx, + q.str, norm_name); + + error = convert_error_code_to_mysql(error, NULL); + } if (error) { innobase_commit_low(trx); -- cgit v1.2.1 From fc4364e3509f9fa625e65f9e124b8133aa103f76 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Aug 2004 15:55:50 +0300 Subject: InnoDB: Add option for disabling innodb_status. 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. 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. files innobase/srv/srv0start.c: innobase_start_or_create_for_mysql(): create srv_monitor_file with tmpfile() or with a visible name "innodb_status.", 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 --- sql/ha_innodb.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 21dd7f748c2..6319c1494d3 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -103,6 +103,7 @@ uint innobase_flush_log_at_trx_commit = 1; my_bool innobase_log_archive = FALSE; my_bool innobase_use_native_aio = FALSE; my_bool innobase_fast_shutdown = TRUE; +my_bool innobase_create_status_file = FALSE; static char *internal_innobase_data_file_path = NULL; @@ -861,6 +862,7 @@ innobase_init(void) srv_force_recovery = (ulint) innobase_force_recovery; srv_fast_shutdown = (ibool) innobase_fast_shutdown; + srv_innodb_status = (ibool) innobase_create_status_file; srv_print_verbose_log = mysql_embedded ? 0 : 1; @@ -4270,7 +4272,7 @@ ha_innobase::update_table_comment( trx_search_latch_release_if_reserved(prebuilt->trx); str = NULL; - if (FILE* file = tmpfile()) { + if (FILE* file = os_file_create_tmpfile()) { long flen; /* output the data to a temporary file */ @@ -4330,7 +4332,7 @@ ha_innobase::get_foreign_key_create_info(void) update_thd(current_thd); - if (FILE* file = tmpfile()) { + if (FILE* file = os_file_create_tmpfile()) { long flen; prebuilt->trx->op_info = (char*)"getting info on foreign keys"; -- cgit v1.2.1 From 2c900be0efd39f971e5a9bebfe5c98e12b56058b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Aug 2004 14:17:32 +0300 Subject: InnoDB: Use create_temp_file() when available innobase/include/os0file.h: Improve the comment of os_file_create_tmpfile() innobase/os/os0file.c: os_file_create_tmpfile(): Use create_temp_file() via innobase_mysql_tmpfile() unless UNIV_HOTBACKUP is defined sql/ha_innodb.cc: Added innobase_mysql_tmpfile(), a wrapper around create_temp_file() --- sql/ha_innodb.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 6319c1494d3..f233dd5a5c5 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -406,6 +406,30 @@ innobase_mysql_print_thd( putc('\n', f); } +/************************************************************************* +Creates a temporary file. */ +extern "C" +int +innobase_mysql_tmpfile(void) +/*========================*/ + /* out: temporary file descriptor, or < 0 on error */ +{ + char filename[FN_REFLEN]; + File fd = create_temp_file(filename, NullS, "ib", +#ifdef __WIN__ + O_BINARY | O_TRUNC | O_SEQUENTIAL | + O_TEMPORARY | O_SHORT_LIVED | +#endif /* __WIN__ */ + O_CREAT | O_EXCL | O_RDWR, + MYF(MY_WME)); +#ifndef __WIN__ + if (fd >= 0) { + unlink(filename); + } +#endif /* !__WIN__ */ + return(fd); +} + /************************************************************************* Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still -- cgit v1.2.1 From 0c062ae60f9dbb21ce3702389f89e4441451d02b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Aug 2004 01:48:01 +0300 Subject: srv0start.c, ut0mem.c, ut0dbg.c, ut0dbg.h, srv0start.h: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) mysqld.cc, ha_innodb.cc: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) sql/ha_innodb.cc: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) sql/mysqld.cc: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) innobase/include/srv0start.h: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) innobase/include/ut0dbg.h: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) innobase/ut/ut0dbg.c: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) innobase/ut/ut0mem.c: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) innobase/srv/srv0start.c: Changes for NetWare to exit the InnoDB gracefully instead of crashing the server (patch by PRam@novell.com, polished a little by Heikki Tuuri) --- sql/ha_innodb.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index f233dd5a5c5..22ddfe779d5 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -121,6 +121,10 @@ char innodb_dummy_stmt_trx_handle = 'D'; static HASH innobase_open_tables; +#ifdef __NETWARE__ /* some special cleanup for NetWare */ +bool nw_panic = FALSE; +#endif + static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length, my_bool not_used __attribute__((unused))); static INNOBASE_SHARE *get_share(const char *table_name); @@ -950,6 +954,11 @@ innobase_end(void) DBUG_ENTER("innobase_end"); +#ifdef __NETWARE__ /* some special cleanup for NetWare */ + if (nw_panic) { + set_panic_flag_for_netware(); + } +#endif err = innobase_shutdown_for_mysql(); hash_free(&innobase_open_tables); my_free(internal_innobase_data_file_path,MYF(MY_ALLOW_ZERO_PTR)); -- cgit v1.2.1 From 03a20c23b320bb28a13aa6dc69c9445ff414a144 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Aug 2004 23:22:16 +0300 Subject: ha_innodb.cc: innobase_mysql_tmpfile(): call dup() and my_close() on the file returned by create_temp_file() in order to avoid memory leak caused by my_open() being paired with close() sql/ha_innodb.cc: innobase_mysql_tmpfile(): call dup() and my_close() on the file returned by create_temp_file() in order to avoid memory leak caused by my_open() being paired with close() --- sql/ha_innodb.cc | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 22ddfe779d5..3d3aca9cfd5 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -31,6 +31,7 @@ have disables the InnoDB inlining in this file. */ #include #include #include +#include #define MAX_ULONG_BIT ((ulong) 1 << (sizeof(ulong)*8-1)) @@ -419,6 +420,7 @@ innobase_mysql_tmpfile(void) /* out: temporary file descriptor, or < 0 on error */ { char filename[FN_REFLEN]; + int fd2 = -1; File fd = create_temp_file(filename, NullS, "ib", #ifdef __WIN__ O_BINARY | O_TRUNC | O_SEQUENTIAL | @@ -426,12 +428,31 @@ innobase_mysql_tmpfile(void) #endif /* __WIN__ */ O_CREAT | O_EXCL | O_RDWR, MYF(MY_WME)); -#ifndef __WIN__ if (fd >= 0) { +#ifndef __WIN__ + /* On Windows, open files cannot be removed, but files can be + created with the O_TEMPORARY flag to the same effect + ("delete on close"). */ unlink(filename); - } #endif /* !__WIN__ */ - return(fd); + /* Copy the file descriptor, so that the additional resources + allocated by create_temp_file() can be freed by invoking + my_close(). + + Because the file descriptor returned by this function + will be passed to fdopen(), it will be closed by invoking + fclose(), which in turn will invoke close() instead of + my_close(). */ + fd2 = dup(fd); + if (fd2 < 0) { + DBUG_PRINT("error",("Got error %d on dup",fd2)); + my_errno=errno; + my_error(EE_OUT_OF_FILERESOURCES, + MYF(ME_BELL+ME_WAITTANG), filename, my_errno); + } + my_close(fd, MYF(MY_WME)); + } + return(fd2); } /************************************************************************* -- cgit v1.2.1 From 06959e0e66ab4640e9e7eea3354c8888ae7acc73 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Sep 2004 16:41:09 +0300 Subject: ha_innodb.cc: If ALTER TABLE ... DROP FOREIGN KEY ... fails because of a wrong constraint name, return a table handler error number 150 instead of 152; the value 152 was misleading, as it referred to '152 = Cannot delete a parent row', whereas '150 = Foreign key constraint is incorrectly formed' is less misleading sql/ha_innodb.cc: If ALTER TABLE ... DROP FOREIGN KEY ... fails because of a wrong constraint name, return a table handler error number 150 instead of 152; the value 152 was misleading, as it referred to '152 = Cannot delete a parent row', whereas '150 = Foreign key constraint is incorrectly formed' is less misleading --- sql/ha_innodb.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/ha_innodb.cc') diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 3d3aca9cfd5..1572e22d6f7 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -285,8 +285,9 @@ convert_error_code_to_mysql( } else if (error == (int) DB_CANNOT_DROP_CONSTRAINT) { - return(HA_ERR_ROW_IS_REFERENCED); - + return(HA_ERR_CANNOT_ADD_FOREIGN); /* TODO: This is a bit + misleading, a new MySQL error + code should be introduced */ } else if (error == (int) DB_COL_APPEARS_TWICE_IN_INDEX) { return(HA_ERR_CRASHED); -- cgit v1.2.1