mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 22:34:18 +01:00
8a3ea85c92
------------------------------------------------------------------------ r5147 | marko | 2009-05-27 06:55:14 -0400 (Wed, 27 May 2009) | 1 line branches/zip: ibuf0ibuf.c: Improve a comment. ------------------------------------------------------------------------ r5149 | marko | 2009-05-27 07:46:42 -0400 (Wed, 27 May 2009) | 34 lines branches/zip: Merge revisions 4994:5148 from branches/5.1: ------------------------------------------------------------------------ r5126 | vasil | 2009-05-26 16:57:12 +0300 (Tue, 26 May 2009) | 9 lines branches/5.1: Preparation for the fix of Bug#45097 Hang during recovery, redo logs for doublewrite buffer pages Non-functional change: move FSP_* macros from fsp0fsp.h to a new file fsp0types.h. This is needed in order to be able to use FSP_EXTENT_SIZE in mtr0log.ic. ------------------------------------------------------------------------ r5127 | vasil | 2009-05-26 17:05:43 +0300 (Tue, 26 May 2009) | 9 lines branches/5.1: Preparation for the fix of Bug#45097 Hang during recovery, redo logs for doublewrite buffer pages Do not include unnecessary headers mtr0log.h and fut0lst.h in trx0sys.h and include fsp0fsp.h just before it is needed. This is needed in order to be able to use TRX_SYS_SPACE in mtr0log.ic. ------------------------------------------------------------------------ r5128 | vasil | 2009-05-26 17:26:37 +0300 (Tue, 26 May 2009) | 7 lines branches/5.1: Fix Bug#45097 Hang during recovery, redo logs for doublewrite buffer pages Do not write redo log for the pages in the doublewrite buffer. Also, do not make a dummy change to the page because this is not needed. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5169 | marko | 2009-05-28 03:21:55 -0400 (Thu, 28 May 2009) | 1 line branches/zip: mtr0mtr.h: Add Doxygen comments for the redo log entry types. ------------------------------------------------------------------------ r5176 | marko | 2009-05-28 07:14:02 -0400 (Thu, 28 May 2009) | 1 line branches/zip: Correct a debug assertion that was added in r5125. ------------------------------------------------------------------------ r5201 | marko | 2009-06-01 06:35:25 -0400 (Mon, 01 Jun 2009) | 2 lines branches/zip: Clean up some comments. Make the rec parameter of mlog_open_and_write_index() const. ------------------------------------------------------------------------ r5234 | marko | 2009-06-03 08:26:41 -0400 (Wed, 03 Jun 2009) | 44 lines branches/zip: Merge revisions 5148:5233 from branches/5.1: ------------------------------------------------------------------------ r5150 | vasil | 2009-05-27 18:56:03 +0300 (Wed, 27 May 2009) | 4 lines branches/5.1: Whitespace fixup. ------------------------------------------------------------------------ r5191 | vasil | 2009-05-30 17:46:05 +0300 (Sat, 30 May 2009) | 19 lines branches/5.1: Merge a change from MySQL (this fixes the failing innodb_mysql test): ------------------------------------------------------------ revno: 1810.3894.10 committer: Sergey Glukhov <Sergey.Glukhov@sun.com> branch nick: mysql-5.0-bugteam timestamp: Tue 2009-05-19 11:32:21 +0500 message: Bug#39793 Foreign keys not constructed when column has a '#' in a comment or default value Internal InnoDN FK parser does not recognize '\'' as quotation symbol. Suggested fix is to add '\'' symbol check for quotation condition (dict_strip_comments() function). modified: innobase/dict/dict0dict.c mysql-test/r/innodb_mysql.result mysql-test/t/innodb_mysql.test ------------------------------------------------------------------------ r5233 | marko | 2009-06-03 15:12:44 +0300 (Wed, 03 Jun 2009) | 11 lines branches/5.1: Merge the test case from r5232 from branches/5.0: ------------------------------------------------------------------------ r5232 | marko | 2009-06-03 14:31:04 +0300 (Wed, 03 Jun 2009) | 21 lines branches/5.0: Merge r3590 from branches/5.1 in order to fix Bug #40565 (Update Query Results in "1 Row Affected" But Should Be "Zero Rows"). Also, add a test case for Bug #40565. rb://128 approved by Heikki Tuuri ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5250 | marko | 2009-06-04 02:58:23 -0400 (Thu, 04 Jun 2009) | 1 line branches/zip: Add Doxygen comments to the rest of buf0*. ------------------------------------------------------------------------ r5251 | marko | 2009-06-04 02:59:51 -0400 (Thu, 04 Jun 2009) | 1 line branches/zip: Replace <= in a function comment. ------------------------------------------------------------------------ r5253 | marko | 2009-06-04 06:37:35 -0400 (Thu, 04 Jun 2009) | 1 line branches/zip: Add missing Doxygen comments for page0zip. ------------------------------------------------------------------------ r5261 | vasil | 2009-06-05 11:13:31 -0400 (Fri, 05 Jun 2009) | 15 lines branches/zip: Fix Mantis Issue#244 fix bug in linear read ahead (no check on access pattern) The changes are: 1) Take into account access pattern when deciding whether or not to do linear read ahead. 2) Expose a knob innodb_read_ahead_factor = [0-64] default (8), dynamic, global to control linear read ahead behvior 3) Disable random read ahead. Keep the code for now. Submitted by: Inaam (rb://122) Approved by: Heikki (rb://122) ------------------------------------------------------------------------ r5262 | vasil | 2009-06-05 12:04:25 -0400 (Fri, 05 Jun 2009) | 22 lines branches/zip: Enable functionality to have multiple background io helper threads. This patch is based on percona contributions. More details about this patch will be written at: https://svn.innodb.com/innobase/MultipleBackgroundThreads The patch essentially does the following: expose following knobs: innodb_read_io_threads = [1 - 64] default 1 innodb_write_io_threads = [1 - 64] default 1 deprecate innodb_file_io_threads (this parameter was relevant only on windows) Internally it allows multiple segments for read and write IO request arrays where one thread works on one segement. Submitted by: Inaam (rb://124) Approved by: Heikki (rb://124) ------------------------------------------------------------------------ r5263 | vasil | 2009-06-05 12:19:37 -0400 (Fri, 05 Jun 2009) | 4 lines branches/zip: Whitespace cleanup. ------------------------------------------------------------------------ r5264 | vasil | 2009-06-05 12:26:58 -0400 (Fri, 05 Jun 2009) | 4 lines branches/zip: Add ChangeLog entry for r5261. ------------------------------------------------------------------------ r5265 | vasil | 2009-06-05 12:34:11 -0400 (Fri, 05 Jun 2009) | 4 lines branches/zip: Add ChangeLog entry for r5262. ------------------------------------------------------------------------ r5268 | inaam | 2009-06-08 12:18:21 -0400 (Mon, 08 Jun 2009) | 7 lines branches/zip Non functional change: Added legal notices acknowledging percona contribution to the multiple IO helper threads patch i.e.: r5262 ------------------------------------------------------------------------ r5283 | inaam | 2009-06-09 13:46:29 -0400 (Tue, 09 Jun 2009) | 9 lines branches/zip rb://130 Enable Group Commit functionality that was broken in 5.0 when distributed transactions were introduced. Reviewed by: Heikki ------------------------------------------------------------------------ r5319 | marko | 2009-06-11 04:40:33 -0400 (Thu, 11 Jun 2009) | 3 lines branches/zip: Declare os_thread_id_t as unsigned long, because ulint is wrong on Win64. Pointed out by Vladislav Vaintroub <wlad@sun.com>. ------------------------------------------------------------------------ r5320 | inaam | 2009-06-11 09:15:41 -0400 (Thu, 11 Jun 2009) | 14 lines branches/zip rb://131 This patch changes the following defaults: max_dirty_pages_pct: default from 90 to 75. max allowed from 100 to 99 additional_mem_pool_size: default from 1 to 8 MB buffer_pool_size: default from 8 to 128 MB log_buffer_size: default from 1 to 8 MB read_io_threads/write_io_threads: default from 1 to 4 The log file sizes are untouched because of upgrade issues Reviewed by: Heikki ------------------------------------------------------------------------ r5330 | marko | 2009-06-16 04:08:59 -0400 (Tue, 16 Jun 2009) | 2 lines branches/zip: buf_page_get_gen(): Reduce mutex holding time by adjusting buf_pool->n_pend_unzip while only holding buf_pool_mutex. ------------------------------------------------------------------------ r5331 | marko | 2009-06-16 05:00:48 -0400 (Tue, 16 Jun 2009) | 2 lines branches/zip: buf_page_get_zip(): Eliminate a buf_page_get_mutex() call. The function must switch on the block state anyway. ------------------------------------------------------------------------ r5332 | vasil | 2009-06-16 05:03:27 -0400 (Tue, 16 Jun 2009) | 4 lines branches/zip: Add ChangeLog entries for r5283 and r5320. ------------------------------------------------------------------------ r5333 | marko | 2009-06-16 05:27:46 -0400 (Tue, 16 Jun 2009) | 1 line branches/zip: buf_page_io_query(): Remove unused function. ------------------------------------------------------------------------ r5335 | marko | 2009-06-16 09:23:10 -0400 (Tue, 16 Jun 2009) | 2 lines branches/zip: innodb.test: Adjust the tolerance of innodb_buffer_pool_pages_total for r5320. ------------------------------------------------------------------------ r5342 | marko | 2009-06-17 06:15:32 -0400 (Wed, 17 Jun 2009) | 60 lines branches/zip: Merge revisions 5233:5341 from branches/5.1: ------------------------------------------------------------------------ r5233 | marko | 2009-06-03 15:12:44 +0300 (Wed, 03 Jun 2009) | 11 lines branches/5.1: Merge the test case from r5232 from branches/5.0: ------------------------------------------------------------------------ r5232 | marko | 2009-06-03 14:31:04 +0300 (Wed, 03 Jun 2009) | 21 lines branches/5.0: Merge r3590 from branches/5.1 in order to fix Bug #40565 (Update Query Results in "1 Row Affected" But Should Be "Zero Rows"). Also, add a test case for Bug #40565. rb://128 approved by Heikki Tuuri ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5243 | sunny | 2009-06-04 03:17:14 +0300 (Thu, 04 Jun 2009) | 14 lines branches/5.1: When the InnoDB and MySQL data dictionaries go out of sync, before the bug fix we would assert on missing autoinc columns. With this fix we allow MySQL to open the table but set the next autoinc value for the column to the MAX value. This effectively disables the next value generation. INSERTs will fail with a generic AUTOINC failure. However, the user should be able to read/dump the table, set the column values explicitly, use ALTER TABLE to set the next autoinc value and/or sync the two data dictionaries to resume normal operations. Fix Bug#44030 Error: (1500) Couldn't read the MAX(ID) autoinc value from the index (PRIMARY) rb://118 ------------------------------------------------------------------------ r5252 | sunny | 2009-06-04 10:16:24 +0300 (Thu, 04 Jun 2009) | 2 lines branches/5.1: The version of the result file checked in was broken in r5243. ------------------------------------------------------------------------ r5259 | vasil | 2009-06-05 10:29:16 +0300 (Fri, 05 Jun 2009) | 7 lines branches/5.1: Remove the word "Error" from the printout because the mysqltest suite interprets it as an error and thus the innodb-autoinc test fails. Approved by: Sunny (via IM) ------------------------------------------------------------------------ r5339 | marko | 2009-06-17 11:01:37 +0300 (Wed, 17 Jun 2009) | 2 lines branches/5.1: Add missing #include "mtr0log.h" so that the code compiles with -DUNIV_MUST_NOT_INLINE. (null merge; this had already been committed in branches/zip) ------------------------------------------------------------------------ r5340 | marko | 2009-06-17 12:11:49 +0300 (Wed, 17 Jun 2009) | 4 lines branches/5.1: row_unlock_for_mysql(): When the clustered index is unknown, refuse to unlock the record. (Bug #45357, caused by the fix of Bug #39320). rb://132 approved by Sunny Bains. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5343 | vasil | 2009-06-17 08:56:12 -0400 (Wed, 17 Jun 2009) | 4 lines branches/zip: Add ChangeLog entry for r5342. ------------------------------------------------------------------------ r5344 | marko | 2009-06-17 09:03:45 -0400 (Wed, 17 Jun 2009) | 1 line branches/zip: row_merge_read_rec(): Fix a UNIV_DEBUG bug (Bug #45426) ------------------------------------------------------------------------ r5391 | marko | 2009-06-22 05:31:35 -0400 (Mon, 22 Jun 2009) | 2 lines branches/zip: buf_page_get_zip(): Fix a bogus warning about block_mutex being possibly uninitialized. ------------------------------------------------------------------------ r5392 | marko | 2009-06-22 07:58:20 -0400 (Mon, 22 Jun 2009) | 4 lines branches/zip: ha_innobase::check_if_incompatible_data(): When ROW_FORMAT=DEFAULT, do not compare to get_row_type(). Without this change, fast index creation will be disabled in recent versions of MySQL 5.1. ------------------------------------------------------------------------ r5393 | pekka | 2009-06-22 09:27:55 -0400 (Mon, 22 Jun 2009) | 4 lines branches/zip: Minor changes for Hot Backup to build correctly. (The code bracketed between #ifdef UNIV_HOTBACKUP and #endif /* UNIV_HOTBACKUP */). This change should not affect !UNIV_HOTBACKUP build. ------------------------------------------------------------------------ r5394 | pekka | 2009-06-22 09:46:34 -0400 (Mon, 22 Jun 2009) | 4 lines branches/zip: Add functions for checking the format of tablespaces for Hot Backup build (UNIV_HOTBACKUP defined). This change should not affect !UNIV_HOTBACKUP build. ------------------------------------------------------------------------ r5397 | calvin | 2009-06-23 16:59:42 -0400 (Tue, 23 Jun 2009) | 7 lines branches/zip: change the header file path. Change the header file path from ../storage/innobase/include/ to ../include/. In the planned 5.1 + plugin release, the source directory of the plugin will not be in storage/innobase. Approved by: Heikki (IM) ------------------------------------------------------------------------ r5407 | calvin | 2009-06-24 09:51:08 -0400 (Wed, 24 Jun 2009) | 4 lines branches/zip: remove relative path of header files. Suggested by Marko. ------------------------------------------------------------------------ r5412 | marko | 2009-06-25 06:27:08 -0400 (Thu, 25 Jun 2009) | 1 line branches/zip: Replace a DBUG_ASSERT with ut_a to track down Issue #290. ------------------------------------------------------------------------ r5415 | marko | 2009-06-25 06:45:57 -0400 (Thu, 25 Jun 2009) | 3 lines branches/zip: dict_index_find_cols(): Print diagnostic on name mismatch. This addresses Bug #44571 but does not fix it. rb://135 approved by Sunny Bains. ------------------------------------------------------------------------ r5417 | marko | 2009-06-25 08:20:56 -0400 (Thu, 25 Jun 2009) | 1 line branches/zip: ha_innodb.cc: Move the misplaced Doxygen @file comment. ------------------------------------------------------------------------ r5418 | marko | 2009-06-25 08:55:52 -0400 (Thu, 25 Jun 2009) | 5 lines branches/zip: Fix a race condition caused by SET GLOBAL innodb_commit_concurrency=DEFAULT. (Bug #45749) When innodb_commit_concurrency is initially set nonzero, DEFAULT would change it back to 0, triggering Bug #42101. rb://139 approved by Heikki Tuuri. ------------------------------------------------------------------------ r5423 | calvin | 2009-06-26 16:52:52 -0400 (Fri, 26 Jun 2009) | 2 lines branches/zip: Fix typos. ------------------------------------------------------------------------ r5425 | marko | 2009-06-29 04:52:30 -0400 (Mon, 29 Jun 2009) | 4 lines branches/zip: ha_innobase::add_index(), ha_innobase::final_drop_index(): Start prebuilt->trx before locking the table. This should fix Issue #293 and could fix Issue #229. Approved by Sunny (over IM). ------------------------------------------------------------------------ r5426 | marko | 2009-06-29 05:24:27 -0400 (Mon, 29 Jun 2009) | 3 lines branches/zip: buf_page_get_gen(): Fix a race condition when reading buf_fix_count. This could explain Issue #156. Tested by Michael. ------------------------------------------------------------------------ r5427 | marko | 2009-06-29 05:54:53 -0400 (Mon, 29 Jun 2009) | 5 lines branches/zip: lock_print_info_all_transactions(), buf_read_recv_pages(): Tolerate missing tablespaces (zip_size==ULINT_UNDEFINED). buf_page_get_gen(): Add ut_ad(ut_is_2pow(zip_size)). Issue #289, rb://136 approved by Sunny Bains ------------------------------------------------------------------------ r5428 | marko | 2009-06-29 07:06:29 -0400 (Mon, 29 Jun 2009) | 2 lines branches/zip: row_sel_store_mysql_rec(): Add missing pointer cast. Do not do arithmetics on void pointers. ------------------------------------------------------------------------ r5429 | marko | 2009-06-29 09:49:54 -0400 (Mon, 29 Jun 2009) | 13 lines branches/zip: Do not crash on SET GLOBAL innodb_file_format=DEFAULT or SET GLOBAL innodb_file_format_check=DEFAULT. innodb_file_format.test: New test for innodb_file_format and innodb_file_format_check. innodb_file_format_name_validate(): Store the string in *save. innodb_file_format_name_update(): Check the string again. innodb_file_format_check_validate(): Store the string in *save. innodb_file_format_check_update(): Check the string again. Issue #282, rb://140 approved by Heikki Tuuri ------------------------------------------------------------------------ r5430 | marko | 2009-06-29 09:58:07 -0400 (Mon, 29 Jun 2009) | 2 lines branches/zip: lock_rec_validate_page(): Add another assertion to track down Issue #289. ------------------------------------------------------------------------ r5431 | marko | 2009-06-29 09:58:40 -0400 (Mon, 29 Jun 2009) | 1 line branches/zip: Revert an accidentally made change in r5430 to univ.i. ------------------------------------------------------------------------ r5437 | marko | 2009-06-30 05:10:01 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: ibuf_dummy_index_free(): Beautify the comment. ------------------------------------------------------------------------ r5438 | marko | 2009-06-30 05:10:32 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: fseg_free(): Remove this unused function. ------------------------------------------------------------------------ r5439 | marko | 2009-06-30 05:15:22 -0400 (Tue, 30 Jun 2009) | 2 lines branches/zip: fseg_validate(): Enclose in #ifdef UNIV_DEBUG. This function is unused, but it could turn out to be a useful debugging aid. ------------------------------------------------------------------------ r5441 | marko | 2009-06-30 06:30:14 -0400 (Tue, 30 Jun 2009) | 2 lines branches/zip: ha_delete(): Remove this unused function that was very similar to ha_search_and_delete_if_found(). ------------------------------------------------------------------------ r5442 | marko | 2009-06-30 06:45:41 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: lock_is_on_table(), lock_table_unlock(): Unused, remove. ------------------------------------------------------------------------ r5443 | marko | 2009-06-30 07:03:00 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: os_event_create_auto(): Unused, remove. ------------------------------------------------------------------------ r5444 | marko | 2009-06-30 07:19:49 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: que_graph_try_free(): Unused, remove. ------------------------------------------------------------------------ r5445 | marko | 2009-06-30 07:28:11 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: row_build_row_ref_from_row(): Unused, remove. ------------------------------------------------------------------------ r5446 | marko | 2009-06-30 07:35:45 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: srv_que_round_robin(), srv_que_task_enqueue(): Unused, remove. ------------------------------------------------------------------------ r5447 | marko | 2009-06-30 07:37:58 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: srv_que_task_queue_check(): Unused, remove. ------------------------------------------------------------------------ r5448 | marko | 2009-06-30 07:56:36 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: mem_heap_cat(): Unused, remove. ------------------------------------------------------------------------ r5449 | marko | 2009-06-30 08:00:50 -0400 (Tue, 30 Jun 2009) | 2 lines branches/zip: innobase_start_or_create_for_mysql(): Invoke os_get_os_version() at most once. ------------------------------------------------------------------------ r5450 | marko | 2009-06-30 08:02:20 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: os_file_close_no_error_handling(): Unused, remove. ------------------------------------------------------------------------ r5451 | marko | 2009-06-30 08:09:49 -0400 (Tue, 30 Jun 2009) | 2 lines branches/zip: page_set_max_trx_id(): Make the code compile with UNIV_HOTBACKUP. ------------------------------------------------------------------------ r5452 | marko | 2009-06-30 08:10:26 -0400 (Tue, 30 Jun 2009) | 2 lines branches/zip: os_file_close_no_error_handling(): Restore, as this function is used within InnoDB Hot Backup. ------------------------------------------------------------------------ r5453 | marko | 2009-06-30 08:14:01 -0400 (Tue, 30 Jun 2009) | 1 line branches/zip: os_process_set_priority_boost(): Unused, remove. ------------------------------------------------------------------------ r5454 | marko | 2009-06-30 08:42:52 -0400 (Tue, 30 Jun 2009) | 2 lines branches/zip: Replace a non-ASCII character (ISO 8859-1 encoded U+00AD SOFT HYPHEN) with a cheap ASCII substitute. ------------------------------------------------------------------------ r5456 | inaam | 2009-06-30 14:21:09 -0400 (Tue, 30 Jun 2009) | 4 lines branches/zip Non functional change. s/Percona/Percona Inc./ ------------------------------------------------------------------------ r5470 | vasil | 2009-07-02 09:12:36 -0400 (Thu, 02 Jul 2009) | 16 lines branches/zip: Use PAUSE instruction inside spinloop if it is available. The patch was originally developed by Mikael Ronstrom <mikael@mysql.com> and can be found here: http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2768 http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2771 http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2772 http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2774 http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2777 http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2799 http://bazaar.launchpad.net/%7Emysql/mysql-server/mysql-5.4/revision/2800 Approved by: Heikki (rb://137) ------------------------------------------------------------------------ r5481 | vasil | 2009-07-06 13:16:32 -0400 (Mon, 06 Jul 2009) | 4 lines branches/zip: Remove unnecessary quotes and simplify plug.in. ------------------------------------------------------------------------ r5482 | calvin | 2009-07-06 18:36:35 -0400 (Mon, 06 Jul 2009) | 5 lines branches/zip: add COPYING files for Percona and Sun Micro. 1.0.4 contains patches based on contributions from Percona and Sun Microsystems. ------------------------------------------------------------------------ r5483 | calvin | 2009-07-07 05:36:43 -0400 (Tue, 07 Jul 2009) | 3 lines branches/zip: add IB_HAVE_PAUSE_INSTRUCTION to CMake. Windows will support PAUSE instruction by default. ------------------------------------------------------------------------ r5484 | inaam | 2009-07-07 18:57:14 -0400 (Tue, 07 Jul 2009) | 13 lines branches/zip rb://126 Based on contribution from Google Inc. This patch introduces a new parameter innodb_io_capacity to control the rate at which master threads performs various tasks. The default value is 200 and higher values imply more aggressive flushing and ibuf merges from within the master thread. This patch also changes the ibuf merge from synchronous to asynchronous. Another minor change is not to force the master thread to wait for a log flush to complete every second. Approved by: Heikki ------------------------------------------------------------------------ r5485 | inaam | 2009-07-07 19:00:49 -0400 (Tue, 07 Jul 2009) | 18 lines branches/zip rb://138 The current implementation is to try to flush the neighbors of every page that we flush. This patch makes the following distinction: 1) If the flush is from flush_list AND 2) If the flush is intended to move the oldest_modification LSN ahead (this happens when a user thread sees little space in the log file and attempts to flush pages from the buffer pool so that a checkpoint can be made) THEN Do not try to flush the neighbors. Just focus on flushing dirty pages at the end of flush_list Approved by: Heikki ------------------------------------------------------------------------ r5486 | inaam | 2009-07-08 12:11:40 -0400 (Wed, 08 Jul 2009) | 29 lines branches/zip rb://133 This patch introduces heuristics based flushing rate of dirty pages to avoid IO bursts at checkpoint. 1) log_capacity / log_generated per second gives us number of seconds in which ALL dirty pages need to be flushed. Based on this rough assumption we can say that n_dirty_pages / (log_capacity / log_generation_rate) = desired_flush_rate 2) We use weighted averages (hard coded to 20 seconds) of log_generation_rate to avoid resonance. 3) From the desired_flush_rate we subtract the number of pages that have been flushed due to LRU flushing. That gives us pages that we should flush as part of flush_list cleanup. And that is the number (capped by maximum io_capacity) that we try to flush from the master thread. Knobs: ====== innodb_adaptive_flushing: boolean, global, dynamic, default TRUE. Since this heuristic is very experimental and has the potential to dramatically change the IO pattern I think it is a good idea to leave a knob to turn it off. Approved by: Heikki ------------------------------------------------------------------------ r5487 | calvin | 2009-07-08 12:42:28 -0400 (Wed, 08 Jul 2009) | 7 lines branches/zip: fix PAUSE instruction patch on Windows The original PAUSE instruction patch (r5470) does not compile on Windows. Also, there is an elegant way of doing it on Windows - YieldProcessor(). Approved by: Heikki (on IM) ------------------------------------------------------------------------ r5489 | vasil | 2009-07-10 05:02:22 -0400 (Fri, 10 Jul 2009) | 9 lines branches/zip: Change the defaults for innodb_sync_spin_loops: 20 -> 30 innodb_spin_wait_delay: 5 -> 6 This change was proposed by Sun/MySQL based on their performance testing, see https://svn.innodb.com/innobase/Release_tasks_for_InnoDB_Plugin_V1.0.4 ------------------------------------------------------------------------ r5490 | vasil | 2009-07-10 05:04:20 -0400 (Fri, 10 Jul 2009) | 4 lines branches/zip: Add ChangeLog entry for 5489. ------------------------------------------------------------------------ r5491 | calvin | 2009-07-10 12:19:17 -0400 (Fri, 10 Jul 2009) | 6 lines branches/zip: add copyright info to files related to PAUSE instruction patch, contributed by Sun Microsystems. ------------------------------------------------------------------------ r5492 | calvin | 2009-07-10 17:47:34 -0400 (Fri, 10 Jul 2009) | 5 lines branches/zip: add ChangeLog entries for r5484-r5486. ------------------------------------------------------------------------ r5494 | vasil | 2009-07-13 03:37:35 -0400 (Mon, 13 Jul 2009) | 6 lines branches/zip: Restore the original value of innodb_sync_spin_loops at the end, previously the test assumed that setting it to 20 will do this, but now the default is 30 and MTR's internal check failed. ------------------------------------------------------------------------ r5495 | inaam | 2009-07-13 11:48:45 -0400 (Mon, 13 Jul 2009) | 5 lines branches/zip rb://138 (REVERT) Revert the flush neighbors patch as it shows regression in the benchmarks run by Michael. ------------------------------------------------------------------------ r5496 | inaam | 2009-07-13 14:04:57 -0400 (Mon, 13 Jul 2009) | 4 lines branches/zip Fixed warnings on windows where ulint != ib_uint64_t ------------------------------------------------------------------------ r5497 | calvin | 2009-07-13 15:01:00 -0400 (Mon, 13 Jul 2009) | 9 lines branches/zip: fix run-time symbols clash on Solaris. This patch is from Sergey Vojtovich of Sun Microsystems, to fix run-time symbols clash on Solaris with older C++ compiler: - when finding out a way to hide symbols, make decision basing on compiler, not operating system. - Sun Studio supports __hidden declaration specifier for this purpose. ------------------------------------------------------------------------ r5498 | vasil | 2009-07-14 03:16:18 -0400 (Tue, 14 Jul 2009) | 92 lines branches/zip: Merge r5341:5497 from branches/5.1, skipping: c5419 because it is merge from branches/zip into branches/5.1 c5466 because the source code has been adjusted to match the MySQL behavior and the innodb-autoinc test does not fail in branches/zip, if c5466 is merged, then innodb-autoinc starts failing, Sunny suggested not to merge c5466. and resolving conflicts in c5410, c5440, c5488: ------------------------------------------------------------------------ r5410 | marko | 2009-06-24 22:26:34 +0300 (Wed, 24 Jun 2009) | 2 lines Changed paths: M /branches/5.1/include/trx0sys.ic M /branches/5.1/trx/trx0purge.c M /branches/5.1/trx/trx0sys.c M /branches/5.1/trx/trx0undo.c branches/5.1: Add missing #include "mtr0log.h" to avoid warnings when compiling with -DUNIV_MUST_NOT_INLINE. ------------------------------------------------------------------------ r5419 | marko | 2009-06-25 16:11:57 +0300 (Thu, 25 Jun 2009) | 18 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc M /branches/5.1/mysql-test/innodb_bug42101-nonzero.result M /branches/5.1/mysql-test/innodb_bug42101-nonzero.test M /branches/5.1/mysql-test/innodb_bug42101.result M /branches/5.1/mysql-test/innodb_bug42101.test branches/5.1: Merge r5418 from branches/zip: ------------------------------------------------------------------------ r5418 | marko | 2009-06-25 15:55:52 +0300 (Thu, 25 Jun 2009) | 5 lines Changed paths: M /branches/zip/ChangeLog M /branches/zip/handler/ha_innodb.cc M /branches/zip/mysql-test/innodb_bug42101-nonzero.result M /branches/zip/mysql-test/innodb_bug42101-nonzero.test M /branches/zip/mysql-test/innodb_bug42101.result M /branches/zip/mysql-test/innodb_bug42101.test branches/zip: Fix a race condition caused by SET GLOBAL innodb_commit_concurrency=DEFAULT. (Bug #45749) When innodb_commit_concurrency is initially set nonzero, DEFAULT would change it back to 0, triggering Bug #42101. rb://139 approved by Heikki Tuuri. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5440 | vasil | 2009-06-30 13:04:29 +0300 (Tue, 30 Jun 2009) | 8 lines Changed paths: M /branches/5.1/fil/fil0fil.c branches/5.1: Fix Bug#45814 URL reference in InnoDB server errors needs adjusting to match documentation by changing the URL from http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html to http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting-datadict.html ------------------------------------------------------------------------ r5466 | vasil | 2009-07-02 10:46:45 +0300 (Thu, 02 Jul 2009) | 6 lines Changed paths: M /branches/5.1/mysql-test/innodb-autoinc.result M /branches/5.1/mysql-test/innodb-autoinc.test branches/5.1: Adjust the failing innodb-autoinc test to conform to the latest behavior of the MySQL code. The idea and the comment in innodb-autoinc.test come from Sunny. ------------------------------------------------------------------------ r5488 | vasil | 2009-07-09 19:16:44 +0300 (Thu, 09 Jul 2009) | 13 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc A /branches/5.1/mysql-test/innodb_bug21704.result A /branches/5.1/mysql-test/innodb_bug21704.test branches/5.1: Fix Bug#21704 Renaming column does not update FK definition by checking whether a column that participates in a FK definition is being renamed and denying the ALTER in this case. The patch was originally developed by Davi Arnaut <Davi.Arnaut@Sun.COM>: http://lists.mysql.com/commits/77714 and was later adjusted to conform to InnoDB coding style by me (Vasil), I also added some more comments and moved the bug specific mysql-test to a separate file to make it more manageable and flexible. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5499 | calvin | 2009-07-14 12:55:10 -0400 (Tue, 14 Jul 2009) | 3 lines branches/zip: add a missing file in Makefile.am This change was suggested by MySQL. ------------------------------------------------------------------------ r5500 | calvin | 2009-07-14 13:03:26 -0400 (Tue, 14 Jul 2009) | 3 lines branches/zip: minor change Remove an extra "with". ------------------------------------------------------------------------ r5501 | vasil | 2009-07-14 13:58:15 -0400 (Tue, 14 Jul 2009) | 5 lines branches/zip: Add @ZLIB_INCLUDES@ so that the InnoDB Plugin picks up the same zlib.h header file that is eventually used by mysqld. ------------------------------------------------------------------------ r5502 | vasil | 2009-07-14 13:59:59 -0400 (Tue, 14 Jul 2009) | 4 lines branches/zip: Add include/ut0auxconf.h to noinst_HEADERS ------------------------------------------------------------------------ r5503 | vasil | 2009-07-14 14:16:11 -0400 (Tue, 14 Jul 2009) | 8 lines branches/zip: Non-functional change: put files in noinst_HEADERS and libinnobase_a_SOURCES one per line and sort alphabetically, so it is easier to find if a file is there or not and also diffs show exactly the added or removed file instead of surrounding lines too. ------------------------------------------------------------------------ r5504 | calvin | 2009-07-15 04:58:44 -0400 (Wed, 15 Jul 2009) | 6 lines branches/zip: fix compile errors on Win64 Both srv_read_ahead_factor and srv_io_capacity should be defined as ulong. Approved by: Sunny ------------------------------------------------------------------------ r5508 | calvin | 2009-07-16 09:40:47 -0400 (Thu, 16 Jul 2009) | 16 lines branches/zip: Support inlining of functions and prefetch with Sun Studio Those changes are contributed by Sun/MySQL. Two sets of changes in this patch when Sun Studio is used: - Explicit inlining of functions - Prefetch Support This patch has been tested by Sunny with the plugin statically built in. Since we've never built the plugin as a dynamically loaded module on Solaris, it is a separate task to change plug.in. rb://142 Approved by: Heikki ------------------------------------------------------------------------ r5509 | calvin | 2009-07-16 09:45:28 -0400 (Thu, 16 Jul 2009) | 2 lines branches/zip: add ChangeLog entry for r5508. ------------------------------------------------------------------------ r5512 | sunny | 2009-07-19 19:52:48 -0400 (Sun, 19 Jul 2009) | 2 lines branches/zip: Remove unused extern ref to timed_mutexes. ------------------------------------------------------------------------ r5513 | sunny | 2009-07-19 19:58:43 -0400 (Sun, 19 Jul 2009) | 2 lines branches/zip: Undo r5512 ------------------------------------------------------------------------ r5514 | sunny | 2009-07-19 20:08:49 -0400 (Sun, 19 Jul 2009) | 2 lines branches/zip: Only use my_bool when UNIV_HOTBACKUP is not defined. ------------------------------------------------------------------------ r5515 | sunny | 2009-07-20 03:29:14 -0400 (Mon, 20 Jul 2009) | 2 lines branches/zip: The dict_table_t::autoinc_mutex field is not used in HotBackup. ------------------------------------------------------------------------ r5516 | sunny | 2009-07-20 03:46:05 -0400 (Mon, 20 Jul 2009) | 4 lines branches/zip: Make this file usable from within HotBackup. A new file has been introduced called hb_univ.i. This file should have all the HotBackup specific configuration. ------------------------------------------------------------------------ r5517 | sunny | 2009-07-20 03:55:11 -0400 (Mon, 20 Jul 2009) | 2 lines Add /* UNIV_HOTBACK */ ------------------------------------------------------------------------ r5519 | vasil | 2009-07-20 04:45:18 -0400 (Mon, 20 Jul 2009) | 31 lines branches/zip: Merge r5497:5518 from branches/5.1: ------------------------------------------------------------------------ r5518 | vasil | 2009-07-20 11:29:47 +0300 (Mon, 20 Jul 2009) | 22 lines Changed paths: M /branches/5.1/handler/ha_innodb.cc branches/5.1: Merge a change from MySQL: ------------------------------------------------------------ revno: 2874.2.1 committer: Anurag Shekhar <anurag.shekhar@sun.com> branch nick: mysql-5.1-bugteam-windows-warning timestamp: Wed 2009-05-13 15:41:24 +0530 message: Bug #39802 On Windows, 32-bit time_t should be enforced This patch fixes compilation warning, "conversion from 'time_t' to 'ulong', possible loss of data". The fix is to typecast time_t to ulong before assigning it to ulong. Backported this from 6.0-bugteam tree. modified: storage/archive/ha_archive.cc storage/federated/ha_federated.cc storage/innobase/handler/ha_innodb.cc storage/myisam/ha_myisam.cc ------------------------------------------------------------------------ ------------------------------------------------------------------------ r5520 | vasil | 2009-07-20 04:51:47 -0400 (Mon, 20 Jul 2009) | 4 lines branches/zip: Add ChangeLog entries for r5498 and r5519. ------------------------------------------------------------------------ r5524 | inaam | 2009-07-20 12:23:15 -0400 (Mon, 20 Jul 2009) | 9 lines branches/zip Change the read ahead parameter name to innodb_read_ahead_threshold. Change the meaning of this parameter to signify the number of pages that must be sequentially accessed for InnoDB to trigger a readahead request. Suggested by: Ken ------------------------------------------------------------------------
706 lines
18 KiB
C
706 lines
18 KiB
C
/*****************************************************************************
|
|
|
|
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*****************************************************************************/
|
|
|
|
/********************************************************************//**
|
|
@file ut/ut0mem.c
|
|
Memory primitives
|
|
|
|
Created 5/11/1994 Heikki Tuuri
|
|
*************************************************************************/
|
|
|
|
#include "ut0mem.h"
|
|
|
|
#ifdef UNIV_NONINL
|
|
#include "ut0mem.ic"
|
|
#endif
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
# include "os0thread.h"
|
|
# include "srv0srv.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
/** This struct is placed first in every allocated memory block */
|
|
typedef struct ut_mem_block_struct ut_mem_block_t;
|
|
|
|
/** The total amount of memory currently allocated from the operating
|
|
system with os_mem_alloc_large() or malloc(). Does not count malloc()
|
|
if srv_use_sys_malloc is set. Protected by ut_list_mutex. */
|
|
UNIV_INTERN ulint ut_total_allocated_memory = 0;
|
|
|
|
/** Mutex protecting ut_total_allocated_memory and ut_mem_block_list */
|
|
UNIV_INTERN os_fast_mutex_t ut_list_mutex;
|
|
|
|
/** Dynamically allocated memory block */
|
|
struct ut_mem_block_struct{
|
|
UT_LIST_NODE_T(ut_mem_block_t) mem_block_list;
|
|
/*!< mem block list node */
|
|
ulint size; /*!< size of allocated memory */
|
|
ulint magic_n;/*!< magic number (UT_MEM_MAGIC_N) */
|
|
};
|
|
|
|
/** The value of ut_mem_block_struct::magic_n. Used in detecting
|
|
memory corruption. */
|
|
#define UT_MEM_MAGIC_N 1601650166
|
|
|
|
/** List of all memory blocks allocated from the operating system
|
|
with malloc. Protected by ut_list_mutex. */
|
|
static UT_LIST_BASE_NODE_T(ut_mem_block_t) ut_mem_block_list;
|
|
|
|
/** Flag: has ut_mem_block_list been initialized? */
|
|
static ibool ut_mem_block_list_inited = FALSE;
|
|
|
|
/** A dummy pointer for generating a null pointer exception in
|
|
ut_malloc_low() */
|
|
static ulint* ut_mem_null_ptr = NULL;
|
|
|
|
/**********************************************************************//**
|
|
Initializes the mem block list at database startup. */
|
|
UNIV_INTERN
|
|
void
|
|
ut_mem_init(void)
|
|
/*=============*/
|
|
{
|
|
ut_a(!ut_mem_block_list_inited);
|
|
os_fast_mutex_init(&ut_list_mutex);
|
|
UT_LIST_INIT(ut_mem_block_list);
|
|
ut_mem_block_list_inited = TRUE;
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/**********************************************************************//**
|
|
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
|
defined and set_to_zero is TRUE.
|
|
@return own: allocated memory */
|
|
UNIV_INTERN
|
|
void*
|
|
ut_malloc_low(
|
|
/*==========*/
|
|
ulint n, /*!< in: number of bytes to allocate */
|
|
ibool set_to_zero, /*!< in: TRUE if allocated memory should be
|
|
set to zero if UNIV_SET_MEM_TO_ZERO is
|
|
defined */
|
|
ibool assert_on_error)/*!< in: if TRUE, we crash mysqld if the
|
|
memory cannot be allocated */
|
|
{
|
|
#ifndef UNIV_HOTBACKUP
|
|
ulint retry_count;
|
|
void* ret;
|
|
|
|
if (UNIV_LIKELY(srv_use_sys_malloc)) {
|
|
ret = malloc(n);
|
|
ut_a(ret || !assert_on_error);
|
|
|
|
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
if (set_to_zero) {
|
|
memset(ret, '\0', n);
|
|
UNIV_MEM_ALLOC(ret, n);
|
|
}
|
|
#endif
|
|
return(ret);
|
|
}
|
|
|
|
ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
|
|
ut_a(ut_mem_block_list_inited);
|
|
|
|
retry_count = 0;
|
|
retry:
|
|
os_fast_mutex_lock(&ut_list_mutex);
|
|
|
|
ret = malloc(n + sizeof(ut_mem_block_t));
|
|
|
|
if (ret == NULL && retry_count < 60) {
|
|
if (retry_count == 0) {
|
|
ut_print_timestamp(stderr);
|
|
|
|
fprintf(stderr,
|
|
" InnoDB: Error: cannot allocate"
|
|
" %lu bytes of\n"
|
|
"InnoDB: memory with malloc!"
|
|
" Total allocated memory\n"
|
|
"InnoDB: by InnoDB %lu bytes."
|
|
" Operating system errno: %lu\n"
|
|
"InnoDB: Check if you should"
|
|
" increase the swap file or\n"
|
|
"InnoDB: ulimits of your operating system.\n"
|
|
"InnoDB: On FreeBSD check you"
|
|
" have compiled the OS with\n"
|
|
"InnoDB: a big enough maximum process size.\n"
|
|
"InnoDB: Note that in most 32-bit"
|
|
" computers the process\n"
|
|
"InnoDB: memory space is limited"
|
|
" to 2 GB or 4 GB.\n"
|
|
"InnoDB: We keep retrying"
|
|
" the allocation for 60 seconds...\n",
|
|
(ulong) n, (ulong) ut_total_allocated_memory,
|
|
#ifdef __WIN__
|
|
(ulong) GetLastError()
|
|
#else
|
|
(ulong) errno
|
|
#endif
|
|
);
|
|
}
|
|
|
|
os_fast_mutex_unlock(&ut_list_mutex);
|
|
|
|
/* Sleep for a second and retry the allocation; maybe this is
|
|
just a temporary shortage of memory */
|
|
|
|
os_thread_sleep(1000000);
|
|
|
|
retry_count++;
|
|
|
|
goto retry;
|
|
}
|
|
|
|
if (ret == NULL) {
|
|
/* Flush stderr to make more probable that the error
|
|
message gets in the error file before we generate a seg
|
|
fault */
|
|
|
|
fflush(stderr);
|
|
|
|
os_fast_mutex_unlock(&ut_list_mutex);
|
|
|
|
/* Make an intentional seg fault so that we get a stack
|
|
trace */
|
|
/* Intentional segfault on NetWare causes an abend. Avoid this
|
|
by graceful exit handling in ut_a(). */
|
|
#if (!defined __NETWARE__)
|
|
if (assert_on_error) {
|
|
ut_print_timestamp(stderr);
|
|
|
|
fprintf(stderr,
|
|
" InnoDB: We now intentionally"
|
|
" generate a seg fault so that\n"
|
|
"InnoDB: on Linux we get a stack trace.\n");
|
|
|
|
if (*ut_mem_null_ptr) ut_mem_null_ptr = 0;
|
|
} else {
|
|
return(NULL);
|
|
}
|
|
#else
|
|
ut_a(0);
|
|
#endif
|
|
}
|
|
|
|
if (set_to_zero) {
|
|
#ifdef UNIV_SET_MEM_TO_ZERO
|
|
memset(ret, '\0', n + sizeof(ut_mem_block_t));
|
|
#endif
|
|
}
|
|
|
|
UNIV_MEM_ALLOC(ret, n + sizeof(ut_mem_block_t));
|
|
|
|
((ut_mem_block_t*)ret)->size = n + sizeof(ut_mem_block_t);
|
|
((ut_mem_block_t*)ret)->magic_n = UT_MEM_MAGIC_N;
|
|
|
|
ut_total_allocated_memory += n + sizeof(ut_mem_block_t);
|
|
|
|
UT_LIST_ADD_FIRST(mem_block_list, ut_mem_block_list,
|
|
((ut_mem_block_t*)ret));
|
|
os_fast_mutex_unlock(&ut_list_mutex);
|
|
|
|
return((void*)((byte*)ret + sizeof(ut_mem_block_t)));
|
|
#else /* !UNIV_HOTBACKUP */
|
|
void* ret = malloc(n);
|
|
ut_a(ret || !assert_on_error);
|
|
|
|
# ifdef UNIV_SET_MEM_TO_ZERO
|
|
if (set_to_zero) {
|
|
memset(ret, '\0', n);
|
|
}
|
|
# endif
|
|
return(ret);
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is
|
|
defined.
|
|
@return own: allocated memory */
|
|
UNIV_INTERN
|
|
void*
|
|
ut_malloc(
|
|
/*======*/
|
|
ulint n) /*!< in: number of bytes to allocate */
|
|
{
|
|
#ifndef UNIV_HOTBACKUP
|
|
return(ut_malloc_low(n, TRUE, TRUE));
|
|
#else /* !UNIV_HOTBACKUP */
|
|
return(malloc(n));
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**********************************************************************//**
|
|
Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs
|
|
out. It cannot be used if we want to return an error message. Prints to
|
|
stderr a message if fails.
|
|
@return TRUE if succeeded */
|
|
UNIV_INTERN
|
|
ibool
|
|
ut_test_malloc(
|
|
/*===========*/
|
|
ulint n) /*!< in: try to allocate this many bytes */
|
|
{
|
|
void* ret;
|
|
|
|
ret = malloc(n);
|
|
|
|
if (ret == NULL) {
|
|
ut_print_timestamp(stderr);
|
|
fprintf(stderr,
|
|
" InnoDB: Error: cannot allocate"
|
|
" %lu bytes of memory for\n"
|
|
"InnoDB: a BLOB with malloc! Total allocated memory\n"
|
|
"InnoDB: by InnoDB %lu bytes."
|
|
" Operating system errno: %d\n"
|
|
"InnoDB: Check if you should increase"
|
|
" the swap file or\n"
|
|
"InnoDB: ulimits of your operating system.\n"
|
|
"InnoDB: On FreeBSD check you have"
|
|
" compiled the OS with\n"
|
|
"InnoDB: a big enough maximum process size.\n",
|
|
(ulong) n,
|
|
(ulong) ut_total_allocated_memory,
|
|
(int) errno);
|
|
return(FALSE);
|
|
}
|
|
|
|
free(ret);
|
|
|
|
return(TRUE);
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/**********************************************************************//**
|
|
Frees a memory block allocated with ut_malloc. */
|
|
UNIV_INTERN
|
|
void
|
|
ut_free(
|
|
/*====*/
|
|
void* ptr) /*!< in, own: memory block */
|
|
{
|
|
#ifndef UNIV_HOTBACKUP
|
|
ut_mem_block_t* block;
|
|
|
|
if (UNIV_LIKELY(srv_use_sys_malloc)) {
|
|
free(ptr);
|
|
return;
|
|
}
|
|
|
|
block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t));
|
|
|
|
os_fast_mutex_lock(&ut_list_mutex);
|
|
|
|
ut_a(block->magic_n == UT_MEM_MAGIC_N);
|
|
ut_a(ut_total_allocated_memory >= block->size);
|
|
|
|
ut_total_allocated_memory -= block->size;
|
|
|
|
UT_LIST_REMOVE(mem_block_list, ut_mem_block_list, block);
|
|
free(block);
|
|
|
|
os_fast_mutex_unlock(&ut_list_mutex);
|
|
#else /* !UNIV_HOTBACKUP */
|
|
free(ptr);
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**********************************************************************//**
|
|
Implements realloc. This is needed by /pars/lexyy.c. Otherwise, you should not
|
|
use this function because the allocation functions in mem0mem.h are the
|
|
recommended ones in InnoDB.
|
|
|
|
man realloc in Linux, 2004:
|
|
|
|
realloc() changes the size of the memory block pointed to
|
|
by ptr to size bytes. The contents will be unchanged to
|
|
the minimum of the old and new sizes; newly allocated mem-
|
|
ory will be uninitialized. If ptr is NULL, the call is
|
|
equivalent to malloc(size); if size is equal to zero, the
|
|
call is equivalent to free(ptr). Unless ptr is NULL, it
|
|
must have been returned by an earlier call to malloc(),
|
|
calloc() or realloc().
|
|
|
|
RETURN VALUE
|
|
realloc() returns a pointer to the newly allocated memory,
|
|
which is suitably aligned for any kind of variable and may
|
|
be different from ptr, or NULL if the request fails. If
|
|
size was equal to 0, either NULL or a pointer suitable to
|
|
be passed to free() is returned. If realloc() fails the
|
|
original block is left untouched - it is not freed or
|
|
moved.
|
|
@return own: pointer to new mem block or NULL */
|
|
UNIV_INTERN
|
|
void*
|
|
ut_realloc(
|
|
/*=======*/
|
|
void* ptr, /*!< in: pointer to old block or NULL */
|
|
ulint size) /*!< in: desired size */
|
|
{
|
|
ut_mem_block_t* block;
|
|
ulint old_size;
|
|
ulint min_size;
|
|
void* new_ptr;
|
|
|
|
if (UNIV_LIKELY(srv_use_sys_malloc)) {
|
|
return(realloc(ptr, size));
|
|
}
|
|
|
|
if (ptr == NULL) {
|
|
|
|
return(ut_malloc(size));
|
|
}
|
|
|
|
if (size == 0) {
|
|
ut_free(ptr);
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t));
|
|
|
|
ut_a(block->magic_n == UT_MEM_MAGIC_N);
|
|
|
|
old_size = block->size - sizeof(ut_mem_block_t);
|
|
|
|
if (size < old_size) {
|
|
min_size = size;
|
|
} else {
|
|
min_size = old_size;
|
|
}
|
|
|
|
new_ptr = ut_malloc(size);
|
|
|
|
if (new_ptr == NULL) {
|
|
|
|
return(NULL);
|
|
}
|
|
|
|
/* Copy the old data from ptr */
|
|
ut_memcpy(new_ptr, ptr, min_size);
|
|
|
|
ut_free(ptr);
|
|
|
|
return(new_ptr);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Frees in shutdown all allocated memory not freed yet. */
|
|
UNIV_INTERN
|
|
void
|
|
ut_free_all_mem(void)
|
|
/*=================*/
|
|
{
|
|
ut_mem_block_t* block;
|
|
|
|
ut_a(ut_mem_block_list_inited);
|
|
ut_mem_block_list_inited = FALSE;
|
|
os_fast_mutex_free(&ut_list_mutex);
|
|
|
|
while ((block = UT_LIST_GET_FIRST(ut_mem_block_list))) {
|
|
|
|
ut_a(block->magic_n == UT_MEM_MAGIC_N);
|
|
ut_a(ut_total_allocated_memory >= block->size);
|
|
|
|
ut_total_allocated_memory -= block->size;
|
|
|
|
UT_LIST_REMOVE(mem_block_list, ut_mem_block_list, block);
|
|
free(block);
|
|
}
|
|
|
|
if (ut_total_allocated_memory != 0) {
|
|
fprintf(stderr,
|
|
"InnoDB: Warning: after shutdown"
|
|
" total allocated memory is %lu\n",
|
|
(ulong) ut_total_allocated_memory);
|
|
}
|
|
}
|
|
#endif /* !UNIV_HOTBACKUP */
|
|
|
|
/**********************************************************************//**
|
|
Copies up to size - 1 characters from the NUL-terminated string src to
|
|
dst, NUL-terminating the result. Returns strlen(src), so truncation
|
|
occurred if the return value >= size.
|
|
@return strlen(src) */
|
|
UNIV_INTERN
|
|
ulint
|
|
ut_strlcpy(
|
|
/*=======*/
|
|
char* dst, /*!< in: destination buffer */
|
|
const char* src, /*!< in: source buffer */
|
|
ulint size) /*!< in: size of destination buffer */
|
|
{
|
|
ulint src_size = strlen(src);
|
|
|
|
if (size != 0) {
|
|
ulint n = ut_min(src_size, size - 1);
|
|
|
|
memcpy(dst, src, n);
|
|
dst[n] = '\0';
|
|
}
|
|
|
|
return(src_size);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Like ut_strlcpy, but if src doesn't fit in dst completely, copies the last
|
|
(size - 1) bytes of src, not the first.
|
|
@return strlen(src) */
|
|
UNIV_INTERN
|
|
ulint
|
|
ut_strlcpy_rev(
|
|
/*===========*/
|
|
char* dst, /*!< in: destination buffer */
|
|
const char* src, /*!< in: source buffer */
|
|
ulint size) /*!< in: size of destination buffer */
|
|
{
|
|
ulint src_size = strlen(src);
|
|
|
|
if (size != 0) {
|
|
ulint n = ut_min(src_size, size - 1);
|
|
|
|
memcpy(dst, src + src_size - n, n + 1);
|
|
}
|
|
|
|
return(src_size);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Make a quoted copy of a NUL-terminated string. Leading and trailing
|
|
quotes will not be included; only embedded quotes will be escaped.
|
|
See also ut_strlenq() and ut_memcpyq().
|
|
@return pointer to end of dest */
|
|
UNIV_INTERN
|
|
char*
|
|
ut_strcpyq(
|
|
/*=======*/
|
|
char* dest, /*!< in: output buffer */
|
|
char q, /*!< in: the quote character */
|
|
const char* src) /*!< in: null-terminated string */
|
|
{
|
|
while (*src) {
|
|
if ((*dest++ = *src++) == q) {
|
|
*dest++ = q;
|
|
}
|
|
}
|
|
|
|
return(dest);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Make a quoted copy of a fixed-length string. Leading and trailing
|
|
quotes will not be included; only embedded quotes will be escaped.
|
|
See also ut_strlenq() and ut_strcpyq().
|
|
@return pointer to end of dest */
|
|
UNIV_INTERN
|
|
char*
|
|
ut_memcpyq(
|
|
/*=======*/
|
|
char* dest, /*!< in: output buffer */
|
|
char q, /*!< in: the quote character */
|
|
const char* src, /*!< in: string to be quoted */
|
|
ulint len) /*!< in: length of src */
|
|
{
|
|
const char* srcend = src + len;
|
|
|
|
while (src < srcend) {
|
|
if ((*dest++ = *src++) == q) {
|
|
*dest++ = q;
|
|
}
|
|
}
|
|
|
|
return(dest);
|
|
}
|
|
|
|
#ifndef UNIV_HOTBACKUP
|
|
/**********************************************************************//**
|
|
Return the number of times s2 occurs in s1. Overlapping instances of s2
|
|
are only counted once.
|
|
@return the number of times s2 occurs in s1 */
|
|
UNIV_INTERN
|
|
ulint
|
|
ut_strcount(
|
|
/*========*/
|
|
const char* s1, /*!< in: string to search in */
|
|
const char* s2) /*!< in: string to search for */
|
|
{
|
|
ulint count = 0;
|
|
ulint len = strlen(s2);
|
|
|
|
if (len == 0) {
|
|
|
|
return(0);
|
|
}
|
|
|
|
for (;;) {
|
|
s1 = strstr(s1, s2);
|
|
|
|
if (!s1) {
|
|
|
|
break;
|
|
}
|
|
|
|
count++;
|
|
s1 += len;
|
|
}
|
|
|
|
return(count);
|
|
}
|
|
|
|
/**********************************************************************//**
|
|
Replace every occurrence of s1 in str with s2. Overlapping instances of s1
|
|
are only replaced once.
|
|
@return own: modified string, must be freed with mem_free() */
|
|
UNIV_INTERN
|
|
char*
|
|
ut_strreplace(
|
|
/*==========*/
|
|
const char* str, /*!< in: string to operate on */
|
|
const char* s1, /*!< in: string to replace */
|
|
const char* s2) /*!< in: string to replace s1 with */
|
|
{
|
|
char* new_str;
|
|
char* ptr;
|
|
const char* str_end;
|
|
ulint str_len = strlen(str);
|
|
ulint s1_len = strlen(s1);
|
|
ulint s2_len = strlen(s2);
|
|
ulint count = 0;
|
|
int len_delta = (int)s2_len - (int)s1_len;
|
|
|
|
str_end = str + str_len;
|
|
|
|
if (len_delta <= 0) {
|
|
len_delta = 0;
|
|
} else {
|
|
count = ut_strcount(str, s1);
|
|
}
|
|
|
|
new_str = mem_alloc(str_len + count * len_delta + 1);
|
|
ptr = new_str;
|
|
|
|
while (str) {
|
|
const char* next = strstr(str, s1);
|
|
|
|
if (!next) {
|
|
next = str_end;
|
|
}
|
|
|
|
memcpy(ptr, str, next - str);
|
|
ptr += next - str;
|
|
|
|
if (next == str_end) {
|
|
|
|
break;
|
|
}
|
|
|
|
memcpy(ptr, s2, s2_len);
|
|
ptr += s2_len;
|
|
|
|
str = next + s1_len;
|
|
}
|
|
|
|
*ptr = '\0';
|
|
|
|
return(new_str);
|
|
}
|
|
|
|
#ifdef UNIV_COMPILE_TEST_FUNCS
|
|
|
|
void
|
|
test_ut_str_sql_format()
|
|
{
|
|
char buf[128];
|
|
ulint ret;
|
|
|
|
#define CALL_AND_TEST(str, str_len, buf, buf_size, ret_expected, buf_expected)\
|
|
do {\
|
|
ibool ok = TRUE;\
|
|
memset(buf, 'x', 10);\
|
|
buf[10] = '\0';\
|
|
fprintf(stderr, "TESTING \"%s\", %lu, %lu\n",\
|
|
str, (ulint) str_len, (ulint) buf_size);\
|
|
ret = ut_str_sql_format(str, str_len, buf, buf_size);\
|
|
if (ret != ret_expected) {\
|
|
fprintf(stderr, "expected ret %lu, got %lu\n",\
|
|
(ulint) ret_expected, ret);\
|
|
ok = FALSE;\
|
|
}\
|
|
if (strcmp((char*) buf, buf_expected) != 0) {\
|
|
fprintf(stderr, "expected buf \"%s\", got \"%s\"\n",\
|
|
buf_expected, buf);\
|
|
ok = FALSE;\
|
|
}\
|
|
if (ok) {\
|
|
fprintf(stderr, "OK: %lu, \"%s\"\n\n",\
|
|
(ulint) ret, buf);\
|
|
} else {\
|
|
return;\
|
|
}\
|
|
} while (0)
|
|
|
|
CALL_AND_TEST("abcd", 4, buf, 0, 0, "xxxxxxxxxx");
|
|
|
|
CALL_AND_TEST("abcd", 4, buf, 1, 1, "");
|
|
|
|
CALL_AND_TEST("abcd", 4, buf, 2, 1, "");
|
|
|
|
CALL_AND_TEST("abcd", 0, buf, 3, 3, "''");
|
|
CALL_AND_TEST("abcd", 1, buf, 3, 1, "");
|
|
CALL_AND_TEST("abcd", 2, buf, 3, 1, "");
|
|
CALL_AND_TEST("abcd", 3, buf, 3, 1, "");
|
|
CALL_AND_TEST("abcd", 4, buf, 3, 1, "");
|
|
|
|
CALL_AND_TEST("abcd", 0, buf, 4, 3, "''");
|
|
CALL_AND_TEST("abcd", 1, buf, 4, 4, "'a'");
|
|
CALL_AND_TEST("abcd", 2, buf, 4, 4, "'a'");
|
|
CALL_AND_TEST("abcd", 3, buf, 4, 4, "'a'");
|
|
CALL_AND_TEST("abcd", 4, buf, 4, 4, "'a'");
|
|
CALL_AND_TEST("abcde", 5, buf, 4, 4, "'a'");
|
|
CALL_AND_TEST("'", 1, buf, 4, 3, "''");
|
|
CALL_AND_TEST("''", 2, buf, 4, 3, "''");
|
|
CALL_AND_TEST("a'", 2, buf, 4, 4, "'a'");
|
|
CALL_AND_TEST("'a", 2, buf, 4, 3, "''");
|
|
CALL_AND_TEST("ab", 2, buf, 4, 4, "'a'");
|
|
|
|
CALL_AND_TEST("abcdef", 0, buf, 5, 3, "''");
|
|
CALL_AND_TEST("abcdef", 1, buf, 5, 4, "'a'");
|
|
CALL_AND_TEST("abcdef", 2, buf, 5, 5, "'ab'");
|
|
CALL_AND_TEST("abcdef", 3, buf, 5, 5, "'ab'");
|
|
CALL_AND_TEST("abcdef", 4, buf, 5, 5, "'ab'");
|
|
CALL_AND_TEST("abcdef", 5, buf, 5, 5, "'ab'");
|
|
CALL_AND_TEST("abcdef", 6, buf, 5, 5, "'ab'");
|
|
CALL_AND_TEST("'", 1, buf, 5, 5, "''''");
|
|
CALL_AND_TEST("''", 2, buf, 5, 5, "''''");
|
|
CALL_AND_TEST("a'", 2, buf, 5, 4, "'a'");
|
|
CALL_AND_TEST("'a", 2, buf, 5, 5, "''''");
|
|
CALL_AND_TEST("ab", 2, buf, 5, 5, "'ab'");
|
|
CALL_AND_TEST("abc", 3, buf, 5, 5, "'ab'");
|
|
|
|
CALL_AND_TEST("ab", 2, buf, 6, 5, "'ab'");
|
|
|
|
CALL_AND_TEST("a'b'c", 5, buf, 32, 10, "'a''b''c'");
|
|
CALL_AND_TEST("a'b'c'", 6, buf, 32, 12, "'a''b''c'''");
|
|
}
|
|
|
|
#endif /* UNIV_COMPILE_TEST_FUNCS */
|
|
#endif /* !UNIV_HOTBACKUP */
|